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:com.firesoft.member.Activity.F0_ProfileActivity.java

public void ToastShow(String atr) {
    ToastView toast = new ToastView(F0_ProfileActivity.this, atr);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();//w w w . jav a  2s. c  o m
}

From source file:ab.util.AbDialogUtil.java

/**
 * ?()//from  w  ww  .j  a v  a 2  s. c o m
 * 
 * @param view
 * @param onCancelListener
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, DialogInterface.OnCancelListener onCancelListener) {
    return showDialog(view, Gravity.CENTER, onCancelListener);
}

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

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (isExit == false) {
            isExit = true;/*  w ww  . j  a v a 2s. c  o  m*/
            ToastView toast = new ToastView(getApplicationContext(), getString(R.string.exit_again));
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
            handler.sendEmptyMessageDelayed(0, 3000);
            return true;
        } else {
            if (SESSION.getInstance().uid == 0) {
                finish();
            } else {
                Intent intent = new Intent(this, SlidingActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish();
            }
            return false;
        }
    }
    return true;
}

From source file:ac.robinson.mediaphone.activity.TemplateBrowserActivity.java

private void initialiseTemplatesView() {
    mTemplates = (NarrativesListView) findViewById(R.id.list_templates);

    // for API 11 and above, buttons are in the action bar
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        LayoutInflater layoutInflater = getLayoutInflater();
        View headerRow = layoutInflater.inflate(R.layout.templates_header, null, false);
        mTemplates.addHeaderView(headerRow, null, false); // false = not selectable
        View emptyView = layoutInflater.inflate(R.layout.templates_empty, null, false);
        ((ViewGroup) mTemplates.getParent()).addView(emptyView);
        mTemplates.setEmptyView(emptyView); // must add separately as the header isn't shown when empty

    } else {//from   ww w  . ja v a  2 s  .co m
        // initial empty list placeholder - add manually as the < v11 version includes the header row
        TextView emptyView = new TextView(TemplateBrowserActivity.this);
        emptyView.setGravity(Gravity.CENTER | Gravity.TOP);
        emptyView.setPadding(10,
                getResources().getDimensionPixelSize(R.dimen.template_list_empty_hint_top_padding), 10, 10); // temporary
        emptyView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        emptyView.setText(getString(R.string.template_list_empty));
        ((ViewGroup) mTemplates.getParent()).addView(emptyView);
        mTemplates.setEmptyView(emptyView);
    }

    mTemplateAdapter = new NarrativeAdapter(this, false, true);
    mTemplates.setAdapter(mTemplateAdapter);
    getSupportLoaderManager().initLoader(R.id.loader_templates_completed, null, this);
    mTemplates.setOnScrollListener(new ScrollManager());
    mTemplates.setOnTouchListener(new FingerTracker());
    mTemplates.setOnItemSelectedListener(new SelectionTracker());
    mTemplates.setOnItemClickListener(new NarrativeViewer());
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE IMAGE ROW/*  w  ww  .  ja  v a  2  s.c  o m*/
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f);
    ImageView img = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value"));
    img.setImageResource(context.getResources().getIdentifier(path, null, null));
    img.setPadding(0, 3, 0, 3);
    container_layout.addView(img, value_params);

    linear.addView(container_layout);
    return linear;
}

From source file:com.ame.armymax.SettingsActivity.java

protected void showToast(String message) {

    Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();

}

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

@Override
public void onClick(View v) {
    String price = mPrice.getText().toString().trim();
    switch (v.getId()) {
    case R.id.top_view_back:
        finish();/*from  w  ww  . j  a v  a2  s.  c om*/
        break;
    case R.id.save:
        if (price.length() == 0 & "".equals(price)) {
            ToastView toast = new ToastView(this, getString(R.string.privce_not_null));
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
            mPrice.requestFocus();
        } else {
            mServiceModel.modify(mMyService.id, price);
        }
        break;
    }
}

From source file:com.achenging.view.SlidingTabLayout.java

public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mTabStrip = new SlidingTabStrip(context);
    int defaultBackgroundColor = mTabStrip.getSolidColor();

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(true);
    // Make sure that the Tab Strips fills this View
    setFillViewport(true);//from  w  w  w  . ja  v  a  2 s. com
    //?
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout);

    //
    mTabSelectedTextColor = typedArray.getColor(R.styleable.SlidingTabLayout_tabSelectedTextColor, 0);
    mTabTextColor = typedArray.getColor(R.styleable.SlidingTabLayout_tabTextColor, 0);

    //
    int selectedIndicatorThickness = (int) typedArray.getDimension(
            R.styleable.SlidingTabLayout_tabIndicatorThickness, SELECTED_INDICATOR_THICKNESS_DIPS);
    //
    int tabIndicatorColor = typedArray.getColor(R.styleable.SlidingTabLayout_tabIndicatorColor,
            DEFAULT_SELECTED_INDICATOR_COLOR);

    //tab
    int tabDividerThickness = (int) typedArray.getDimension(R.styleable.SlidingTabLayout_dividerThickness,
            DEFAULT_DIVIDER_THICKNESS_DIPS);
    //tab
    int tabDividerColor = typedArray.getColor(R.styleable.SlidingTabLayout_dividerColor,
            defaultBackgroundColor);

    //tab??
    int tabBottomBorderThickness = (int) typedArray.getDimension(
            R.styleable.SlidingTabLayout_bottomBorderThickness, DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS);
    int tabBottomBorderColor = typedArray.getColor(R.styleable.SlidingTabLayout_bottomBorderColor,
            defaultBackgroundColor);

    //?tab?
    boolean showAsDivider = typedArray.getBoolean(R.styleable.SlidingTabLayout_showAsDivider, false);

    typedArray.recycle();
    //

    //        mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);

    mTextPadding = (int) (DEFAULT_TEXT_PADDING * getResources().getDisplayMetrics().density);

    //
    setSelectedTitleColors(mTabSelectedTextColor);
    setUnSelectedTitleColors(mTabTextColor);
    setDividerColors(tabDividerColor);
    setSelectedIndicatorColors(tabIndicatorColor);
    setTabBottomBorderColor(tabBottomBorderColor);
    setTabDividerColor(tabDividerColor);
    //
    setSelectedIndicatorThickness(selectedIndicatorThickness);
    setTabBottomBorderThickness(tabBottomBorderThickness);
    setTabDividerThickness(tabDividerThickness);
    setShowAsDivider(showAsDivider);
    setShowTabDivider(false);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.CENTER;
    addView(mTabStrip);
}

From source file:android.support.v7ox.widget.ScrollingTabContainerView.java

private LinearLayoutCompat createTabLayout() {
    final LinearLayoutCompat tabLayout = new LinearLayoutCompat(getContext(), null,
            R.attr.actionBarTabBarStyle_ox);
    tabLayout.setMeasureWithLargestChildEnabled(true);
    tabLayout.setGravity(Gravity.CENTER);
    tabLayout.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.WRAP_CONTENT,
            LinearLayoutCompat.LayoutParams.MATCH_PARENT));
    return tabLayout;
}

From source file:codepath.watsiapp.activities.BaseFragmentActivity.java

private void showThankYouNote() {
    LayoutInflater inflater = this.getLayoutInflater();
    View view = inflater.inflate(R.layout.toast_thanks_for_donation,
            (ViewGroup) this.findViewById(R.id.thanks_note));
    Toast toast = new Toast(this);
    toast.setView(view);/*from   w  w w.j  a  va 2 s  .  c o  m*/
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.show();

}