List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:com.actionbarsherlock.sample.demos.app.ActionBarActionItemCustomView.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.add(0, android.R.id.copy, 0, "Test"); final int twentyDp = (int) (20 * getResources().getDisplayMetrics().density); TypedArray a = getTheme().obtainStyledAttributes(R.styleable.SherlockTheme); final int abHeight = a.getLayoutDimension(R.styleable.SherlockTheme_abHeight, LayoutParams.FILL_PARENT); a.recycle();/* w w w.ja v a 2 s . c o m*/ LinearLayout l = new LinearLayout(this); l.setPadding(twentyDp, 0, twentyDp, 20); l.setBackgroundColor(0x55FF0000); TextView tv = new TextView(this); tv.setText("HI!!"); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, abHeight)); l.addView(tv); l.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(ActionBarActionItemCustomView.this, "Got custom action item click!", Toast.LENGTH_SHORT).show(); } }); item.setActionView(l); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return super.onCreateOptionsMenu(menu); }
From source file:com.alibaba.akita.samples.TestFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) { mContent = savedInstanceState.getString(KEY_CONTENT); }//ww w . java2 s . c o m TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); text.setPadding(20, 20, 20, 20); LinearLayout layout = new LinearLayout(getActivity()); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER); layout.addView(text); return layout; }
From source file:com.aengbee.android.leanback.presenter.GridItemPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); Resources res = parent.getResources(); int width = res.getDimensionPixelSize(R.dimen.grid_item_width); int height = res.getDimensionPixelSize(R.dimen.grid_item_height); view.setLayoutParams(new ViewGroup.LayoutParams(width, height)); view.setFocusable(true);/* w w w .jav a2 s . c o m*/ view.setFocusableInTouchMode(true); view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:com.aashreys.walls.application.views.ChipViewModel.java
int getGravity() { return Gravity.CENTER; }
From source file:com.art2cat.dev.moonlightnote.controller.settings.CommonSettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment if (getArguments() != null) { mType = getArguments().getInt("type"); }// w ww. java2 s . c o m LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); linearLayout.setLayoutParams(params); ScrollView scrollView = new ScrollView(getActivity()); scrollView.setLayoutParams(params); linearLayout.addView(scrollView); TextView textView = new TextView(getActivity()); textView.setLayoutParams(params); int padding = getResources().getDimensionPixelOffset(R.dimen.padding); textView.setPadding(padding, padding, padding, padding); switch (mType) { case Constants.FRAGMENT_ABOUT: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_about); break; case Constants.FRAGMENT_LICENSE: textView.setGravity(Gravity.CENTER); textView.setText(getContent()); getActivity().setTitle(R.string.settings_license); break; case Constants.FRAGMENT_POLICY: textView.setGravity(Gravity.START); textView.setText(getContent()); getActivity().setTitle(R.string.settings_policy); break; } setHasOptionsMenu(true); scrollView.addView(textView); return linearLayout; }
From source file:android.hqs.view.pager.indicator.IconPageIndicator.java
public IconPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); mIconsLayout = new IcsLinearLayout(context, R.attr.vpiIconPageIndicatorStyle); addView(mIconsLayout,/*w w w . j a va 2s . com*/ new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, Gravity.CENTER)); }
From source file:am.project.x.business.widgets.tagtabstrip.TagTabStripActivity.java
private ArrayList<View> getPagers() { ArrayList<View> views = new ArrayList<>(); for (int i = 0; i < 5; 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 v a 2 s. c om*/ views.add(text); } return views; }
From source file:com.example.android.networkconnect.SimpleTextFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Before initializing the textView, check if any arguments were provided via setArguments. processArguments();/*from ww w . j ava2 s .c o m*/ // Create a new TextView and set its text to whatever was provided. mTextView = new TextView(getActivity()); mTextView.setGravity(Gravity.CENTER); if (mText != null) { mTextView.setText(mText); Log.i("SimpleTextFragment", mText); } return mTextView; }
From source file:com.app.laundry.tabs.lib.IconPageIndicator2.java
public IconPageIndicator2(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); mIconsLayout = new IcsLinearLayout2(context, R.attr.vpiIconPageIndicatorStyle); addView(mIconsLayout, new LayoutParams(WRAP_CONTENT, FILL_PARENT, Gravity.CENTER)); }
From source file:android_hddl_framework.viewpagerindicator.IconPageIndicator.java
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)); }