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.android.browser.GearsPermissionsDialog.java

public void setup() {
    inflate(R.layout.gears_dialog_permission, R.id.panel_content);
    setupButtons(R.string.permission_button_alwaysdeny, R.string.permission_button_allow,
            R.string.permission_button_deny);

    try {/*from   w w w.  ja v  a2 s.  c o m*/
        JSONObject json = new JSONObject(mDialogArguments);

        if (json.has("dialogType")) {
            mDialogType = json.getString("dialogType");
            setupDialog();
        }

        if (!json.has("customName")) {
            setLabel(json, "origin", R.id.origin_title);
            View titleView = findViewById(R.id.origin_title);
            if (titleView != null) {
                TextView title = (TextView) titleView;
                title.setGravity(Gravity.CENTER);
            }
        } else {
            setLabel(json, "customName", R.id.origin_title);
            setLabel(json, "origin", R.id.origin_subtitle);
            setLabel(json, "customMessage", R.id.origin_message);
        }

        if (json.has("customIcon")) {
            String iconUrl = json.getString("customIcon");
            mChoosenIconSize = 32;
            downloadIcon(iconUrl);
        }

        View msg = findViewById(R.id.permission_dialog_message);
        if (msg != null) {
            TextView dialogMessage = (TextView) msg;
            if (mDialogType.equalsIgnoreCase(LOCAL_DATA_STRING)) {
                dialogMessage.setText(R.string.query_data_message);
            } else if (mDialogType.equalsIgnoreCase(LOCATION_DATA_STRING)) {
                dialogMessage.setText(R.string.location_message);
            }
        }

    } catch (JSONException e) {
        Log.e(TAG, "JSON exception ", e);
    }
}

From source file:com.ateam.shippingcity.widget.viewpagerindicator.IconPageIndicator.java

@SuppressWarnings("deprecation")
public IconPageIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false);

    mIconsLayout = new IcsLinearLayout(context, R.attr.vpiIconPageIndicatorStyle);
    addView(mIconsLayout, new LayoutParams(WRAP_CONTENT, FILL_PARENT, Gravity.CENTER));
}

From source file:fragments.NewTicket.java

@Override
public void onResume() {
    super.onResume();
    Window window = getDialog().getWindow();
    window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    window.setGravity(Gravity.CENTER);
}

From source file:com.spoiledmilk.cykelsuperstier.break_rote.TransportationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transportation);
    ((ImageButton) findViewById(R.id.btnBack)).setOnClickListener(new OnClickListener() {
        @Override//w w  w  .  j  av  a  2s. com
        public void onClick(View v) {
            finish();
            overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
        }
    });
    ((TextView) findViewById(R.id.textTitle)).setVisibility(View.VISIBLE);
    ((TextView) findViewById(R.id.textTitle)).setGravity(Gravity.CENTER);
    if (getIntent().hasExtra("fromStation"))
        fromStation = getIntent().getExtras().getString("fromStation");
    if (getIntent().hasExtra("toStation"))
        toStation = getIntent().getExtras().getString("toStation");
    if (getIntent().hasExtra("line"))
        line = getIntent().getExtras().getString("line");
    // if (getIntent().hasExtra("lineB"))
    // lineB = getIntent().getExtras().getString("lineB");
    if (getIntent().hasExtra("destX"))
        destX = getIntent().getExtras().getDouble("destX");
    if (getIntent().hasExtra("destY"))
        destY = getIntent().getExtras().getDouble("destY");
    if (getIntent().hasExtra("timeToAStation"))
        minutesToAStation = getIntent().getExtras().getInt("timeToAStation");

    if (minutesToAStation < 0)
        minutesToAStation = 20;// safety check when time hasn't been
    // calculated
    if ((LocalTrainData.hasLine(line, this)))
        getStationsData();
    else
        getTimetableFromRejsplanen();

}

From source file:am.project.x.business.widgets.indicatortabstrip.IndicatorTabStripActivity.java

private ArrayList<View> getPagers() {
    ArrayList<View> views = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        TextView text = new TextView(this);
        text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180);
        text.setText(String.format(Locale.getDefault(), "%d", i + 1));
        text.setGravity(Gravity.CENTER);
        text.setTextColor(0xff000000);//from  ww  w  . j  a  va2 s . c  o m
        views.add(text);
    }
    return views;
}

From source file:cn.yunt.www.pagerslidingtabstrip.SuperAwesomeCardFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*from www.  j  av a 2  s .c o m*/

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.ageelg.android.testviewpagerwslider.SuperAwesomeCardFragment.java

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

    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.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);//from ww  w  .j av  a2s. c o  m
    return fl;
}

From source file:com.astuetz.SuperAwesomeCardFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*ww w .  j ava  2s .  c  om*/

    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.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.arta.lib.demo.widget.pagerslidingtabstrip.SuperAwesomeCardFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//from   w  w  w .ja v  a2 s. c  o  m

    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.setBackgroundResource(R.drawable.pagerslidingtabstrip_background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.manning.androidhacks.hack005.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);// w w w  . j  a va  2  s. c om

    mTextSwitcher = (TextSwitcher) findViewById(R.id.your_textview);

    mTextSwitcher.setFactory(new ViewFactory() {
        @Override
        public View makeView() {
            TextView t = new TextView(MainActivity.this);
            t.setGravity(Gravity.CENTER);
            return t;
        }
    });

    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);

    onSwitchText(null);
}