Example usage for android.widget LinearLayout setGravity

List of usage examples for android.widget LinearLayout setGravity

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setGravity(int gravity) 

Source Link

Document

Describes how the child views are positioned.

Usage

From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java

public View createLoadingView() {
    ScrollView sv = new ScrollView(getActivity());
    sv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    sv.setTag("gg_scroll");
    sv.setFillViewport(true);/*from w  ww  .  j  a  v  a  2 s.c o  m*/
    LinearLayout l = new LinearLayout(getActivity());
    l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    l.setGravity(Gravity.CENTER);

    ProgressBar pb = new ProgressBar(getActivity());
    pb.getIndeterminateDrawable().setColorFilter(SIAApp.SIA_APP.school.getAccentColor(),
            PorterDuff.Mode.SRC_IN);
    pb.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    pb.setVisibility(ProgressBar.VISIBLE);

    l.addView(pb);
    sv.addView(l);
    return sv;
}

From source file:org.mariotaku.twidere.fragment.support.BasePullToRefreshMultiColumnListFragment.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   ww  w . j a  v  a  2  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(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();
    final FrameLayout root = new FrameLayout(context);

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

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

    final 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));

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

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final 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));

    final PullToRefreshLayout plv = new PullToRefreshLayout(context);
    mPullToRefreshLayout = plv;

    final MultiColumnListView lv = createMultiColumnListView(context, inflater);
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    plv.addView(lv, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    final Options.Builder builder = new Options.Builder();
    builder.scrollDistance(DEFAULT_PULL_TO_REFRESH_SCROLL_DISTANCE);
    builder.headerTransformer(new TwidereHeaderTransformer());
    if (!isDetached() && getActivity() != null) {
        final SetupWizard wizard = ActionBarPullToRefresh.from(getActivity());
        wizard.allChildrenArePullable();
        wizard.useViewDelegate(MultiColumnListView.class, new PLAAbsListViewDelegate());
        wizard.listener(this);
        wizard.options(builder.build());
        wizard.setup(mPullToRefreshLayout);
    }
    // ViewCompat.setOverScrollMode(lv, ViewCompat.OVER_SCROLL_NEVER);
    lframe.addView(plv, 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));

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

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

    return root;
}

From source file:org.sufficientlysecure.keychain.remote.ui.SelectPublicKeyFragment.java

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

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

    ProgressBar progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);

    progressContainer.addView(progressBar, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

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

    FrameLayout listContainer = new FrameLayout(context);
    listContainer.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView textView = new TextView(context);
    textView.setId(INTERNAL_EMPTY_VIEW_ID);
    textView.setGravity(Gravity.CENTER);

    listContainer.addView(textView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    LinearLayout innerListContainer = new LinearLayout(context);
    innerListContainer.setOrientation(LinearLayout.VERTICAL);

    mSearchView = new EditText(context);
    mSearchView.setId(android.R.id.input);
    mSearchView.setHint(R.string.menu_search);
    mSearchView.setCompoundDrawablesWithIntrinsicBounds(
            ContextCompat.getDrawable(context, R.drawable.ic_search_grey_24dp), null, null, null);

    innerListContainer.addView(mSearchView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    RecyclerView listView = new RecyclerView(context);
    listView.setId(INTERNAL_LIST_VIEW_ID);

    int padding = FormattingUtils.dpToPx(context, 8);
    listView.setPadding(padding, 0, padding, 0);
    listView.setClipToPadding(false);//  w ww .  j  av  a 2 s.  c o  m

    innerListContainer.addView(listView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    listContainer.addView(innerListContainer, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(listContainer, 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:com.efan.notlonely_android.view.PagerSlidingTabStrip.java

private ViewGroup getTabsLayout() {
    if (tabsLayout == null) {
        if (getChildCount() > 0) {
            tabsLayout = (ViewGroup) getChildAt(0);
        } else {/*from w  ww .j a  va  2  s.c om*/
            removeAllViews();
            LinearLayout tabsLayout = new LinearLayout(getContext());
            tabsLayout.setGravity(Gravity.CENTER_VERTICAL);
            this.tabsLayout = tabsLayout;
            addView(tabsLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
                    Gravity.CENTER_VERTICAL));
        }
    }
    return tabsLayout;
}

From source file:com.dwdesign.tweetings.fragment.PullToRefreshListFragment.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. j av  a 2s. 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(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

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

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

    final 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));

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

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final 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));

    final PullToRefreshListView plv = new PullToRefreshListView(context);
    plv.setOnRefreshListener(this);
    mPullToRefreshListView = plv;

    final ListView lv = plv.getRefreshableView();
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(plv, 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));

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

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

    return root;
}

From source file:org.mariotaku.twidere.fragment.PullToRefreshListFragment.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 ww .  ja  v a  2  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(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

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

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

    final ProgressBar progress = new HoloProgressBar(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));

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

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final 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));

    final PullToRefreshListView plv = new PullToRefreshListView(context);
    plv.setOnRefreshListener(this);
    mPullToRefreshListView = plv;

    final ListView lv = plv.getRefreshableView();
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(plv, 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));

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

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

    return root;
}

From source file:pl.bcichecki.rms.client.android.dialogs.RegisterDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    context = getActivity();/*from  w ww.  j  a v a 2  s  .  com*/

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(getString(R.string.dialog_register_title));
    builder.setMessage(getString(R.string.dialog_register_message));

    final EditText usernameEditText = new EditText(getActivity());
    usernameEditText.setHint(getString(R.string.dialog_register_enter_username_hint));
    usernameEditText.setMaxLines(1);
    usernameEditText.setSingleLine();
    usernameEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    usernameEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            usernameEditText.setError(null);
        }

    });

    final EditText passwordEditText = new EditText(getActivity());
    passwordEditText.setHint(getString(R.string.dialog_register_enter_password_hint));
    passwordEditText.setMaxLines(1);
    passwordEditText.setSingleLine();
    passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    passwordEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            passwordEditText.setError(null);
        }

    });

    final EditText emailEditText = new EditText(getActivity());
    emailEditText.setHint(getString(R.string.dialog_register_enter_email_hint));
    emailEditText.setMaxLines(1);
    emailEditText.setSingleLine();
    emailEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    emailEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            emailEditText.setError(null);
        }

    });

    final LinearLayout layout = new LinearLayout(getActivity());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    int space = (int) AppUtils.convertDpToPixel(getActivity(), 16);
    layout.setPadding(space, 0, space, 0);

    layout.addView(usernameEditText);
    layout.addView(passwordEditText);
    layout.addView(emailEditText);

    builder.setView(layout);

    builder.setPositiveButton(getString(R.string.dialog_register_ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            return;
        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {
            utilitiesRestClient = new UtilitiesRestClient(getActivity(),
                    SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(),
                    SharedPreferencesWrapper.getWebserviceContextPath());

            final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (!AppUtils.checkInternetConnection(getActivity())) {
                        Log.d(TAG, "There is NO network connected!");
                        return;
                    }

                    usernameEditText.setError(null);
                    passwordEditText.setError(null);
                    emailEditText.setError(null);

                    if (StringUtils.isBlank(usernameEditText.getText().toString())) {
                        usernameEditText.setError(getString(R.string.dialog_register_field_required));
                        return;
                    }
                    if (StringUtils.isBlank(passwordEditText.getText().toString())) {
                        passwordEditText.setError(getString(R.string.dialog_register_field_required));
                        return;
                    }
                    if (StringUtils.isBlank(emailEditText.getText().toString())) {
                        emailEditText.setError(getString(R.string.dialog_register_field_required));
                        return;
                    }
                    if (!AppUtils.validateEmail(emailEditText.getText().toString())) {
                        emailEditText.setError(getString(R.string.dialog_register_email_not_valid));
                        return;
                    }

                    final User user = new User();
                    user.setUsername(usernameEditText.getText().toString());
                    user.setPassword(SecurityUtils.hashSHA512Base64(passwordEditText.getText().toString()));
                    user.setEmail(StringUtils.lowerCase(emailEditText.getText().toString()));
                    user.setAddress(new AddressData());

                    utilitiesRestClient.registerUser(user, new AsyncHttpResponseHandler() {

                        @Override
                        public void onFailure(Throwable error, String content) {
                            Log.d(TAG,
                                    "Registering user failed. [error= " + error + ", content=" + content + "]");
                            AppUtils.showCenteredToast(context, getString(R.string.dialog_register_failed),
                                    Toast.LENGTH_LONG);
                        }

                        @Override
                        public void onFinish() {
                            positiveButton.setEnabled(true);
                        }

                        @Override
                        public void onStart() {
                            Log.d(TAG, "Registering user: " + user.toString());
                            AppUtils.showCenteredToast(context, getString(R.string.dialog_register_in_progress),
                                    Toast.LENGTH_SHORT);
                            positiveButton.setEnabled(false);
                        }

                        @Override
                        public void onSuccess(int statusCode, String content) {
                            Log.d(TAG, "Registered user successfully.");
                            AppUtils.showCenteredToast(context, getString(R.string.dialog_register_successful),
                                    Toast.LENGTH_SHORT);

                            SharedPreferencesWrapper.setUsername(user.getUsername());
                            SharedPreferencesWrapper.setPasswordHash(user.getPassword());
                            SharedPreferencesWrapper.setRememberUser(true);

                            dialog.dismiss();
                        }

                    });

                }
            });

            final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
            negativeButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    cancelRequests();
                    dialog.dismiss();
                }
            });

        }
    });

    return dialog;
}

From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java

private LinearLayout titleLayout() {
    LinearLayout titleLayout = new LinearLayout(context);
    LayoutParams layoutParams = new LayoutParams(UZCoreUtil.dipToPix(width - iconSize - 30),
            UZCoreUtil.dipToPix(height));
    layoutParams.setMargins(UZCoreUtil.dipToPix(10), 0, UZCoreUtil.dipToPix(10), 0);
    titleLayout.setLayoutParams(layoutParams);
    titleLayout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout titleLayout2 = new LinearLayout(context);
    LayoutParams layoutParams2 = new LayoutParams(UZCoreUtil.dipToPix(width - iconSize - 30),
            UZCoreUtil.dipToPix(height - 10));
    titleLayout2.setGravity(Gravity.CENTER_VERTICAL);
    titleLayout2.setOrientation(LinearLayout.VERTICAL);
    titleLayout2.setLayoutParams(layoutParams2);
    titleLayout.addView(titleLayout2);/*from  ww  w.ja va 2 s  .c  o m*/
    titleLayout2.addView(title());
    titleLayout2.addView(subTitle());
    return titleLayout;
}

From source file:org.mariotaku.twidere.fragment.support.BaseSupportListFragment.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 .java2  s .  co 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(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

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

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

    final 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));

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

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

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

    final 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));

    root.addView(lframe, 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:com.umeng.comm.ui.emoji.EmojiBorad.java

/**
 * </br>//from w  w w . ja  va2s  . c o m
 * 
 * @return
 */
private ViewGroup createPointLinearlayout() {
    LinearLayout pointContainerLayout = new LinearLayout(getContext());
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pointContainerLayout.setLayoutParams(params);
    pointContainerLayout.setOrientation(LinearLayout.HORIZONTAL);
    pointContainerLayout.setGravity(Gravity.CENTER);
    params.gravity = Gravity.CENTER;
    params.topMargin = DeviceUtils.dp2px(getContext(), 15);
    params.bottomMargin = DeviceUtils.dp2px(getContext(), 15);
    return pointContainerLayout;
}