List of usage examples for android.widget TextView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.visk.xperiatuner.cpucontrol.CpuControlFragment.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);// www . ja va 2s . 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.background_card); // v.setText("CARD " + (position + 1)); v.setText("CARD "); fl.addView(v); return fl; }
From source file:com.collcloud.frame.viewpager.main.Fragment1.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);/* w w w .j a v a 2 s. co 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.tab_pagertab_background_card); v.setText("fragment1 CARD is " + (position + 1)); fl.addView(v); return fl; }
From source file:com.collcloud.frame.viewpager.main.Fragment2.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);/* w ww . 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.tab_pagertab_background_card); v.setText("fragment2 CARD is " + (position + 1)); fl.addView(v); return fl; }
From source file:com.collcloud.frame.viewpager.main.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 . jav a 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.tab_pagertab_background_card); v.setText("CARD is " + (position + 1)); fl.addView(v); return fl; }
From source file:com.xwj.toolbardemo.BaseCardFragment.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);// w ww .j a va2 s . c o m fl.setBackgroundResource(drawables[position]); 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.BOTTOM); v.setText("fragment " + (position + 1)); fl.addView(v); return fl; }
From source file:com.example.toolbar.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 ww w .ja v a2 s . c om*/ fl.setBackgroundResource(drawables[position]); 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.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.ijiaban.tabslide.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()); TuiJFragment TJ = new TuiJFragment(); fl.setLayoutParams(params);/*from w w w. j av a2s . 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)); getChildFragmentManager().beginTransaction().add(TJ, ARG_POSITION); fl.addView(v); return fl; }
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();/*from w w w .ja v a 2 s .co 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.aaagame.proframework.fragment.T_PaletteFragment.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 ww. j a v a 2s. co m*/ fl.setBackgroundResource(drawables[position]); 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.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.commnsense.proximity.fragments.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);// w w w.ja va 2 s .c om fl.setBackgroundColor(0xffa9a9a9); 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; }