Example usage for android.widget FrameLayout FrameLayout

List of usage examples for android.widget FrameLayout FrameLayout

Introduction

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

Prototype

public FrameLayout(@NonNull Context context) 

Source Link

Usage

From source file:com.facebook.android.FbDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    popupProgressItem = new PopupItem();
    popupProgressDialogFragment = PopupProgressFragment.newInstance(popupProgressItem);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mContent = new FrameLayout(getContext());

    /* Create the 'x' image, but don't add to the mContent layout yet
     * at this point, we only need to know its drawable width and height
     * to place the webview/* w  ww  . ja v  a2  s.co  m*/
     */
    createCrossImage();

    /* Now we know 'x' drawable width and height,
     * layout the webivew and add it the mContent layout
     */
    int crossWidth = mCrossImage.getDrawable().getIntrinsicWidth();
    setUpWebView(crossWidth / 2);

    /* Finally add the 'x' image to the mContent layout and
     * add mContent to the Dialog view
     */
    mContent.addView(mCrossImage, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    addContentView(mContent, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}

From source file:com.ekuater.labelchat.ui.fragment.userInfo.HeaderFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Activity activity = getActivity();
    assert activity != null;
    mFrameLayout = new FrameLayout(activity);

    mCover = onCoverView(inflater, mFrameLayout);

    mHeader = onCreateHeaderView(inflater, mFrameLayout);
    mHeaderHeader = mHeader.findViewById(android.R.id.title);
    mHeaderBackground = mHeader.findViewById(android.R.id.background);
    assert mHeader.getLayoutParams() != null;
    mHeaderHeight = mHeader.getLayoutParams().height;

    mFakeHeader = new Space(activity);
    mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight));

    View content = onCreateContentView(inflater, mFrameLayout);
    if (content instanceof RelativeLayout) {
        isListViewEmpty = true;/*from   w  w w .  j  a v  a2s  .  c  o  m*/

        final ListView listView = (ListView) content.findViewById(R.id.list);
        listView.addHeaderView(mFakeHeader);
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScrollStateChanged(absListView, scrollState);
                }
            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount);
                }

                if (isListViewEmpty) {
                    scrollHeaderTo(0);
                } else {
                    final View child = absListView.getChildAt(0);
                    assert child != null;
                    scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight);
                }
            }
        });
    } else {

        // Merge fake header view and content view.
        final LinearLayout view = new LinearLayout(activity);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setOrientation(LinearLayout.VERTICAL);
        view.addView(mFakeHeader);
        view.addView(content);

        // Put merged content to ScrollView
        final NotifyingScrollView scrollView = new NotifyingScrollView(activity);
        scrollView.addView(view);
        scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() {
            @Override
            public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
                scrollHeaderTo(-t);
            }
        });
        content = scrollView;
    }

    mFrameLayout.addView(content);
    mFrameLayout.addView(mHeader);
    if (mCover != null) {
        mFrameLayout.addView(mCover);
    }
    // Post initial scroll
    mFrameLayout.post(new Runnable() {
        @Override
        public void run() {
            scrollHeaderTo(0, true);
        }
    });

    return mFrameLayout;
}

From source file:org.mariotaku.twidere.fragment.support.SetUserNicknameDialogFragment.java

@NonNull
@Override/* w  ww .  ja  va  2s .c om*/
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String nick = args.getString(EXTRA_NAME);
    final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
    final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
    builder.setTitle(R.string.set_nickname);
    builder.setPositiveButton(android.R.string.ok, this);
    if (!TextUtils.isEmpty(nick)) {
        builder.setNeutralButton(R.string.clear, this);
    }
    builder.setNegativeButton(android.R.string.cancel, null);
    final FrameLayout view = new FrameLayout(wrapped);
    mEditText = new AppCompatEditText(wrapped);
    final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.leftMargin = lp.topMargin = lp.bottomMargin = lp.rightMargin = getResources()
            .getDimensionPixelSize(R.dimen.element_spacing_normal);
    view.addView(mEditText, lp);
    builder.setView(view);
    mEditText.setText(nick);
    return builder.create();
}

From source file:de.vanita5.twittnuker.fragment.support.SetUserNicknameDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final String nick = args.getString(EXTRA_NAME);
    final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
    final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
    builder.setTitle(R.string.set_nickname);
    builder.setPositiveButton(android.R.string.ok, this);
    if (!TextUtils.isEmpty(nick)) {
        builder.setNeutralButton(R.string.clear, this);
    }//from  w w w.j av  a2s . c o m
    builder.setNegativeButton(android.R.string.cancel, null);
    final FrameLayout view = new FrameLayout(wrapped);
    mEditText = new EditText(wrapped);
    final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.leftMargin = lp.topMargin = lp.bottomMargin = lp.rightMargin = getResources()
            .getDimensionPixelSize(R.dimen.element_spacing_normal);
    view.addView(mEditText, lp);
    builder.setView(view);
    mEditText.setText(nick);
    return builder.create();
}

From source file:com.chrslee.csgopedia.app.CardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //Looks like he did this layout via code this is a layoutparams object
    //it defines the metrics and bounds of a specific view
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    //Creating a FrameLayout a FrameLayout is basically a empty container
    FrameLayout fl = new FrameLayout(context);
    fl.setLayoutParams(params);//  ww  w  .j ava 2 s. c  o m
    //setting the params from above

    // First - image section
    //Building the imageview via code
    LayoutParams imgParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    imgParams.gravity = Gravity.CENTER;
    //setting all centered
    ImageView iv = new ImageView(context);
    iv.setLayoutParams(imgParams);
    iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    iv.setAdjustViewBounds(true);
    iv.setBackgroundResource(getActivity().getIntent().getExtras().getInt("iconID"));
    //seting the iconID as the image of this imageView

    // Second - prices section
    //final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
    //        .getDisplayMetrics());
    //

    //LinearLayout is another container it just take the
    //widgets inside it and display them in a linear order
    LinearLayout linLayout = new LinearLayout(context);
    linLayout.setOrientation(LinearLayout.VERTICAL);
    linLayout.setLayoutParams(params);
    linLayout.setGravity(Gravity.CENTER);

    // Get prices
    ConnectionDetector cd = new ConnectionDetector(context); //creating a connection detector to check for internet
    String query = getActivity().getIntent().getStringExtra("searchQuery"); //taking the name or whatever he pass from mainactivity from the searchquery arg
    TextView placeholder = new TextView(context); ///this is a textview for the name of the item
    if (cd.isConnectedToInternet()) {//if its connected to internet then
        if (query.equals("-1")) {//if the skin is regular he display is not for sale
            placeholder.setText("Regular skins are not for sale!");
            linLayout.addView(placeholder);
        } else {//else he calls the scrappperAsyncTask with the query
            new ScraperAsyncTask(linLayout).execute(query);
        }
    } else {//if its not connected he display the message here
        placeholder.setText("Please connect to the Internet to view prices.");
        linLayout.addView(placeholder);
    }

    //here he defines which tab he is displaying, Now I see why he used the same fragment,
    //this is a bad practice, he created both widgets before but just displays one of them
    //for each case if its the first tab he display the image if its the second the prices
    if (position == 0) {
        fl.addView(iv);
    } else {
        fl.addView(linLayout);
    }

    //Then he returns the framelayout (container) to display it in the screen
    return fl;
}

From source file:com.codeslap.topy.BaseMultiPaneActivity.java

public View getTwoColumns(Fragment firstFragment, float firstWeight, Fragment secondFragment,
        float secondWeight) {
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    int firstId = 1;
    int secondId = 2;

    FrameLayout firstLayout = new FrameLayout(this);
    LinearLayout.LayoutParams firstParams = new LinearLayout.LayoutParams(0,
            LinearLayout.LayoutParams.FILL_PARENT);
    firstParams.weight = firstWeight;//from   w  w  w.  j av a 2s . c  om
    firstLayout.setLayoutParams(firstParams);
    firstLayout.setId(firstId);

    FrameLayout secondLayout = new FrameLayout(this);
    LinearLayout.LayoutParams secondParams = new LinearLayout.LayoutParams(0,
            LinearLayout.LayoutParams.FILL_PARENT);
    secondLayout.setLayoutParams(secondParams);
    secondParams.weight = secondWeight;
    secondLayout.setId(secondId);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(firstId, firstFragment);
    ft.add(2, secondFragment);
    ft.commit();

    linearLayout.addView(firstLayout);
    linearLayout.addView(secondLayout);

    return linearLayout;
}

From source file:com.ubiLive.GameCloud.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.setFullscreen(this);
    Utils.setNoTitle(this);
    if (GameActivity.m_player == null) {
        Utils.ShowOKPromptLoadLibError(this, "Error", "Sorry,Device Model is not supported.",
                new DialogInterface.OnClickListener() {
                    @Override//from  www.  j av a  2s. c  o  m
                    public void onClick(DialogInterface dialog, int which) {
                        MainActivity.this.finish();
                    }
                });
        return;
    }
    mGCParse = GCApplication.getApplication().getGCParse();
    if (mGCParse != null && mGCParse.track(this)) {
        return;
    }
    DebugLog.d(TAG, "onCreate");
    mFrameLayout = new FrameLayout(this);
    mFrameLayout.setLayoutParams(
            new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    setContentView(mFrameLayout);
    mViewPager = initIntroPage(mFrameLayout);
    mEula = initEulaPage(mFrameLayout);
    if (mEula == null && mViewPager == null) {
        checkContentlicenseAction();
    }
}

From source file:prince.app.ccm.Fragment_Turnos.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    FrameLayout wrapper = new FrameLayout(getActivity());
    View view = inflater.inflate(R.layout.layout_web, wrapper, true);

    setUp(view);//from   www.  ja v a2 s  . c o  m

    return view;
}

From source file:com.xalops.spotifystreamer.fragments.SearchListFragment.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>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.
 *///ww  w .  ja v  a 2 s  . c  om
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout root = new FrameLayout(context);

    //QUICK Inflate from XML file

    //inflater.inflate(R.layout.search_list_detail, root);
    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    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.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    RelativeLayout rlayout = new RelativeLayout(context);

    EditText et = new EditText(getActivity());
    et.setId(INTERNAL_SEARCH_FIELD_ID);
    et.setSingleLine(true);
    et.setInputType(InputType.TYPE_CLASS_TEXT);
    et.setImeOptions(EditorInfo.IME_ACTION_DONE);
    RelativeLayout.LayoutParams etRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    RelativeLayout.LayoutParams lframeRLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    lframeRLayoutParams.addRule(RelativeLayout.BELOW, INTERNAL_SEARCH_FIELD_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));

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

    rlayout.addView(et, etRLayoutParams);
    rlayout.addView(lframe, lframeRLayoutParams);
    root.addView(rlayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

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

    return root;
}

From source file:org.telegram.ui.FeaturedStickersActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/*from  ww w  .  ja v a2s. c om*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    RecyclerListView listView = new RecyclerListView(context);
    listView.setItemAnimator(null);
    listView.setLayoutAnimation(null);
    listView.setFocusable(true);
    listView.setTag(14);
    layoutManager = new LinearLayoutManager(context) {
        @Override
        public boolean supportsPredictiveItemAnimations() {
            return false;
        }
    };
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    listView.setLayoutManager(layoutManager);

    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
        @Override
        public void onItemClick(final View view, int position) {
            if (position >= stickersStartRow && position < stickersEndRow && getParentActivity() != null) {
                final TLRPC.StickerSetCovered stickerSet = StickersQuery.getFeaturedStickerSets().get(position);
                TLRPC.InputStickerSet inputStickerSet;
                if (stickerSet.set.id != 0) {
                    inputStickerSet = new TLRPC.TL_inputStickerSetID();
                    inputStickerSet.id = stickerSet.set.id;
                } else {
                    inputStickerSet = new TLRPC.TL_inputStickerSetShortName();
                    inputStickerSet.short_name = stickerSet.set.short_name;
                }
                inputStickerSet.access_hash = stickerSet.set.access_hash;
                StickersAlert stickersAlert = new StickersAlert(getParentActivity(),
                        FeaturedStickersActivity.this, inputStickerSet, null, null);
                stickersAlert.setInstallDelegate(new StickersAlert.StickersAlertInstallDelegate() {
                    @Override
                    public void onStickerSetInstalled() {
                        FeaturedStickerSetCell cell = (FeaturedStickerSetCell) view;
                        cell.setDrawProgress(true);
                        installingStickerSets.put(stickerSet.set.id, stickerSet);
                    }

                    @Override
                    public void onStickerSetUninstalled() {

                    }
                });
                showDialog(stickersAlert);
            }
        }
    });
    return fragmentView;
}