Example usage for android.view Gravity CENTER

List of usage examples for android.view Gravity CENTER

Introduction

In this page you can find the example usage for android.view Gravity CENTER.

Prototype

int CENTER

To view the source code for android.view Gravity CENTER.

Click Source Link

Document

Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.

Usage

From source file:agronet.mpayer.zegetech.com.mpayercashbox.fragments.HomeMenuFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    switch (position) {
    case 0://from   w w  w .j ava 2 s  . c  om
        View view = inflater.inflate(R.layout.fragment_home, container, false);

        TextView tv = (TextView) view.findViewById(R.id.orders);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnOrders = (ImageView) view.findViewById(R.id.ordersBtn);
        btnOrders.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), OrdersActivity.class);
                startActivity(i);
            }
        });
        tv = (TextView) view.findViewById(R.id.transactions);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnTransactions = (ImageView) view.findViewById(R.id.transactionsBtn);
        btnTransactions.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), TransactionsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.accounts);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnAccounts = (ImageView) view.findViewById(R.id.accountsBtn);
        btnAccounts.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), AccountsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.members);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnMembers = (ImageView) view.findViewById(R.id.membersBtn);
        btnMembers.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), MembersActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.reports);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnReports = (ImageView) view.findViewById(R.id.reportsBtn);
        btnReports.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), ReportsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.settings);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnSettings = (ImageView) view.findViewById(R.id.settingsBtn);
        btnSettings.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), SettingsActivity.class);
                startActivity(i);
            }
        });
        return view;
    case 1:
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        FrameLayout fl = new FrameLayout(getActivity());

        fl.setLayoutParams(params);

        final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                getResources().getDisplayMetrics());
        TextView v = new TextView(getActivity());
        params.setMargins(margin, margin, margin, margin);
        v.setLayoutParams(params);
        v.setLayoutParams(params);
        v.setGravity(Gravity.CENTER);
        v.setText("LOG");

        fl.addView(v);
        return fl;
    }
    return null;
}

From source file:com.ass.ui.View.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* w  w w .  j ava  2s. c om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    return textView;
}

From source file:com.app.the.bunker.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*w  w w.  ja v  a2s .c  o m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
    textView.setTypeface(Typeface.DEFAULT);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.insthub.O2OMobile.Activity.D3_OrderCommentActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.d12_star_one:
        selectRank(1);/*w  w w . ja v a  2  s .c o m*/
        break;
    case R.id.d12_star_two:
        selectRank(2);
        break;
    case R.id.d12_star_three:
        selectRank(3);
        break;
    case R.id.d12_star_four:
        selectRank(4);
        break;
    case R.id.d12_star_five:
        selectRank(5);
        break;
    case R.id.d12_publish_button: {
        if (mCommentRank == 0) {
            ToastView toast = new ToastView(this, getString(R.string.please_choose_servic_evaluation));
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        } else {
            if (null != mOrder_info) {
                mCommentModel.comment(mCommentContent.getText().toString(), mCommentRank, mOrder_info.id);
            } else {
                mCommentModel.comment(mCommentContent.getText().toString(), mCommentRank, 1);
            }

        }
    }
    }
}

From source file:com.bangqu.eshow.util.ESDialogUtil.java

/**
 * /*from ww w .jav  a  2  s. co m*/
 * ???.
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @param onCancelListener
 * @return
 */
public static ESSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int style, DialogInterface.OnCancelListener onCancelListener) {
    return showDialog(view, animEnter, animExit, animPopEnter, animPopExit, Gravity.CENTER, style,
            onCancelListener);
}

From source file:co.ronash.pushesample.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//ww w. j  a  v  a2s .  com
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.actionbarsherlock.internal.widget.IcsSpinner.java

/**
 * Construct a new spinner with the given context's theme, the supplied attribute set,
 * and default style./*from  w  w  w.  j a  v  a2 s  .c  o  m*/
 *
 * @param context The Context the view is running in, through which it can
 *        access the current theme, resources, etc.
 * @param attrs The attributes of the XML tag that is inflating the view.
 * @param defStyle The default style to apply to this view. If 0, no style
 *        will be applied (beyond what is included in the theme). This may
 *        either be an attribute resource, whose value will be retrieved
 *        from the current theme, or an explicit style resource.
 */
public IcsSpinner(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockSpinner, defStyle, 0);

    DropdownPopup popup = new DropdownPopup(context, attrs, defStyle);

    mDropDownWidth = a.getLayoutDimension(R.styleable.SherlockSpinner_android_dropDownWidth,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popup.setBackgroundDrawable(a.getDrawable(R.styleable.SherlockSpinner_android_popupBackground));
    final int verticalOffset = a
            .getDimensionPixelOffset(R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0);
    if (verticalOffset != 0) {
        popup.setVerticalOffset(verticalOffset);
    }

    final int horizontalOffset = a
            .getDimensionPixelOffset(R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0);
    if (horizontalOffset != 0) {
        popup.setHorizontalOffset(horizontalOffset);
    }

    mPopup = popup;

    mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER);

    mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt));

    mDisableChildrenWhenDisabled = true;

    a.recycle();

    // Base constructor can call setAdapter before we initialize mPopup.
    // Finish setting things up if this happened.
    if (mTempAdapter != null) {
        mPopup.setAdapter(mTempAdapter);
        mTempAdapter = null;
    }
}

From source file:ca.qc.johnabbott.cs603.ExternalLibraries.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from   w w w  .ja va  2  s . c o  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    textView.setTextColor(context.getResources().getColor(R.color.colorSecondary));

    return textView;
}

From source file:acc.healthapp.tabs.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* w  w  w.ja va 2s  .c  o m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:cn.org.eshow.framwork.util.AbDialogUtil.java

/**
 * /*  w w w  . ja v  a2  s.  c o m*/
 * ???.
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @param onCancelListener
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int style, DialogInterface.OnCancelListener onCancelListener) {
    return showDialog(view, animEnter, animExit, animPopEnter, animPopExit, Gravity.CENTER, style,
            onCancelListener);
}