Example usage for android.widget FrameLayout setLayoutParams

List of usage examples for android.widget FrameLayout setLayoutParams

Introduction

In this page you can find the example usage for android.widget FrameLayout setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:br.unb.mobileMedia.core.view.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 * <p/>//from   ww w . j  a  v  a2  s .c  o  m
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:de.memorian.ps4trophaen.util.ExpandableListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        lastExpandedPosition = savedInstanceState.getInt(LAST_EXP_POS, -1);
    }//  w ww. j a v  a  2 s . c om
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:libraries.stackoverflow.ExpandableListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty./*from w  w  w  . ja  va 2 s.c  om*/
 * <p/>
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    FrameLayout lframe = new FrameLayout(getActivity());
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    ListView.LayoutParams lp = new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
}

From source file:org.protocoderrunner.apprunner.api.PUI.java

@ProtocoderScript
@APIMethod(description = "Adds a processing view", example = "")
@APIParam(params = { "x", "y", "w", "h", "mode={'p2d', 'p3d'" })
public PApplet addProcessing(int x, int y, int w, int h, String mode) {

    initializeLayout();/*  www  . j  a  v a  2 s .co m*/

    // Create the main layout. This is where all the items actually go
    FrameLayout fl = new FrameLayout(a.get());
    fl.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    fl.setId(200 + (int) (200 * Math.random()));
    fl.setBackgroundResource(R.color.transparent);

    // Add the view
    addViewAbsolute(fl, x, y, w, h);

    PProcessing p = new PProcessing();

    Bundle bundle = new Bundle();
    bundle.putString("mode", mode);
    p.setArguments(bundle);

    FragmentTransaction ft = appRunnerActivity.get().getSupportFragmentManager().beginTransaction();
    ft.add(fl.getId(), p, String.valueOf(fl.getId()));

    // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    // ft.setCustomAnimations(android.R.anim.fade_in,
    // android.R.anim.fade_out);
    ft.addToBackStack(null);
    ft.commit();

    return p;

}

From source file:com.android.calculator2.Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout root = new FrameLayout(context);

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);/*from   w w w  .  j  a va  2 s . c o  m*/

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_VIEW_CONTAINER_ID);

    View cv = inflateView(savedInstanceState);
    cv.setId(android.R.id.content);
    lframe.addView(cv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    return root;
}

From source file:info.tellmetime.TellmetimeActivity.java

/**
 * Handles changing highlight color via #mSeekBarHighlight.
 *
 * @param value indicates exact offset in gradient (SeekBar's max value is equal to #mRainbow width).
 *//*from www.  ja  v a2s .  c o m*/
@Override
public void onProgressChanged(SeekBar seekBar, int value, boolean fromUser) {
    switch (seekBar.getId()) {
    case R.id.highlightValue:
        mHighlightColor = mRainbow.getPixel(value, 0);
        if (((RadioButton) findViewById(R.id.radio_backlight_highlight)).isChecked()) {
            float[] highlightHSV = new float[3];
            Color.colorToHSV(mHighlightColor, highlightHSV);
            mBacklightColor = Color.HSVToColor(33, highlightHSV);
        }
        if (fromUser)
            mHighlightPosition = (float) value / seekBar.getMax();

        mClockAlgorithm.tickTock();

        break;

    case R.id.minutesSize:
        mMinutesSize = value;

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            FrameLayout minutesIndicators = (FrameLayout) findViewById(R.id.minutes_indicators);
            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) minutesIndicators
                    .getLayoutParams();
            params.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3,
                    getResources().getDisplayMetrics());
            minutesIndicators.setLayoutParams(params);
        }

        ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots);
        for (int i = 0; i < minutesDots.getChildCount(); i++) {
            TextView m = (TextView) minutesDots.getChildAt(i);
            m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize);
        }

        break;
    }

    mHider.delayedHide(4000);
}

From source file:im.ene.lab.toro.ext.layeredvideo.PlaybackControlLayer.java

/**
 * Fullscreen mode will rotate to landscape mode, hide the action bar, hide the navigation bar,
 * hide the system tray, and make the video player take up the full size of the display.
 * The developer who is using this function must ensure the following:
 *
 * <p>1) Inside the android manifest, the activity that uses the video player has the attribute
 * android:configChanges="orientation".//  w  w w . j a  va 2 s  . c om
 *
 * <p>2) Other views in the activity (or fragment) are
 * hidden (or made visible) when this method is called.
 */
public void doToggleFullscreen() {
    // If there is no callback for handling fullscreen, don't do anything.
    if (fullscreenCallback == null) {
        return;
    }

    ObservablePlayerControl playerControl = layerManager.getControl();
    if (playerControl == null) {
        return;
    }

    Activity activity = layerManager.getActivity();
    FrameLayout container = layerManager.getContainer();

    if (isFullscreen) {
        activity.setRequestedOrientation(savedOrientation);

        // Make the status bar and navigation bar visible again.
        activity.getWindow().getDecorView().setSystemUiVisibility(0);

        container.setLayoutParams(originalContainerLayoutParams);

        fullscreenButton.setImageResource(R.drawable.toro_ext_ic_fullscreen_enter);

        fullscreenCallback.onReturnFromFullscreen();
        isFullscreen = false;
    } else {
        savedOrientation = activity.getResources().getConfiguration().orientation;
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        activity.getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

        container.setLayoutParams(PlayerUtil.getLayoutParamsBasedOnParent(container,
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        fullscreenButton.setImageResource(R.drawable.toro_ext_ic_fullscreen_exit);
        fullscreenCallback.onGoToFullscreen();
        isFullscreen = true;
    }
}

From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java

private void goLargeLandscape() {
    isFullscreen = false;/*ww w.  j  a v  a2 s.  c om*/
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

    VideoController videoControls = (VideoController) findViewById(R.id.controller);
    if (videoControls != null) {
        videoControls.setFullscreen(false);
    }

    ThumbnailWrapper videoContainer = (ThumbnailWrapper) findViewById(R.id.video_fragment_container);
    videoContainer.setMaintainAspectRatio(true);

    FrameLayout headerContainer = (FrameLayout) findViewById(R.id.detail_header_container);
    LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) headerContainer.getLayoutParams();
    p.weight = 1;
    headerContainer.setLayoutParams(p);
    headerContainer.setVisibility(View.VISIBLE);

    FrameLayout emptyContainer = (FrameLayout) findViewById(R.id.detail_bottom_container);
    p = (LinearLayout.LayoutParams) emptyContainer.getLayoutParams();
    p.weight = 0;
    emptyContainer.setLayoutParams(p);
    emptyContainer.setVisibility(View.GONE);

    findViewById(R.id.detail_right_container).setVisibility(View.VISIBLE);
    createAndAttachCaptionFragment(R.id.detail_right_caption_container);
    createAndAttachHeader();

    findViewById(R.id.detail_center_divider).setVisibility(View.VISIBLE);

    getDecorViewTreeObserver().addOnGlobalLayoutListener(layoutFixer);
}

From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java

private void goPortrait() {
    isFullscreen = false;//from  www.  java  2 s  .  c  o  m
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

    VideoController videoControls = (VideoController) findViewById(R.id.controller);
    if (videoControls != null) {
        videoControls.setFullscreen(false);
    }

    ThumbnailWrapper videoContainer = (ThumbnailWrapper) findViewById(R.id.video_fragment_container);
    videoContainer.setMaintainAspectRatio(true);

    FrameLayout headerContainer = (FrameLayout) findViewById(R.id.detail_header_container);
    LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) headerContainer.getLayoutParams();
    p.weight = 0;
    headerContainer.setLayoutParams(p);

    createAndAttachCaptionFragment(R.id.detail_bottom_container);
    FrameLayout captionContainer = (FrameLayout) findViewById(R.id.detail_bottom_container);
    captionContainer.setVisibility(View.VISIBLE);
    p = (LinearLayout.LayoutParams) captionContainer.getLayoutParams();
    p.weight = 1;
    captionContainer.setLayoutParams(p);

    if (isBigScreen) {
        findViewById(R.id.detail_right_container).setVisibility(View.GONE);
        findViewById(R.id.detail_center_divider).setVisibility(View.GONE);
    }

    setNavVisibility(true);
    createAndAttachHeader();

    getDecorViewTreeObserver().addOnGlobalLayoutListener(layoutFixer);
}

From source file:com.openatk.fieldnotebook.MainActivity.java

private void hideDrawing(Boolean transition) {
    if (drawingIsShowing == 1) {
        drawingIsShowing = 0;//from   w  w  w  . jav  a2 s  . c o m
        FragmentManager fm = getSupportFragmentManager();
        FragmentDrawing fragment = (FragmentDrawing) fm.findFragmentByTag("drawing");
        // Set height so transition works
        FrameLayout layout = (FrameLayout) findViewById(R.id.fragment_container_drawing);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layout.getLayoutParams();
        params.height = fragment.getHeight();
        layout.setLayoutParams(params);
        // Do transition
        FragmentTransaction ft = fm.beginTransaction();
        if (transition)
            ft.setCustomAnimations(R.anim.slide_down2, R.anim.slide_up2);
        ft.remove(fragment);
        ft.commit();
        fragmentDrawing = null;
    }
    this.invalidateOptionsMenu();
}