List of usage examples for android.widget TextView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the Disk usage for each disk. * //from w ww . j a v a 2 s. c om * @return a ScrollView containing a list of AFBarView and AFPieView. */ private View createDiskListDialog() { // use the scroll view to scale ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getDisk_percent_part(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = Double.parseDouble(item.getValue()); String name = item.getName(); LinearLayout row = createTableRow(LinearLayout.HORIZONTAL); AFPieView pieView = createPieView(value); row.addView(pieView); TextView text = new TextView(this); text.setPadding(10, 0, 0, 0); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(String.format("%s - %.1f %s used", name, value, "%")); row.addView(text); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:com.aashir.gmote.player.widget.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 ww. jav a 2s .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); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); 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.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the Disk busy for each disk. * //w w w. j a v a2 s . com * @return a ScrollView containing a list of AFBarView and AFPieView. */ private View createDiskBusyListDialog() { ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getDisk_busy(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = 0.0; try { value = Double.parseDouble(item.getValue()); } catch (Exception e) { e.printStackTrace(); continue; } String name = item.getName(); LinearLayout row = createTableRow(LinearLayout.VERTICAL); TextView text = new TextView(this); text.setPadding(5, 0, 0, 0); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(name); AFBarView barView = createBarView(value); row.addView(barView); row.addView(text); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:com.tony.selene.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab./*from www. ja v a2 s. c o m*/ * * @param tabTexts * the tab texts * @param fragments * the fragments */ public void addItemViews(List<String> tabTexts, List<Fragment> fragments) { tabItemTextList.addAll(tabTexts); pagerItemList.addAll(fragments); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } // ? mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.tony.selene.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab.//from www. j av a 2 s. c o m * * @param tabText * the tab text * @param fragment * the fragment */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } // ? AbLogUtil.d(AbSlidingSmoothFixTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.dreamspace.superman.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)}./*from www . j ava 2 s .co m*/ */ protected View createDefaultTabView(Context context) { View v; if (mIconAdapter == null) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT); textView.setAllCaps(true); textView.setTextColor(getStartColor()); if (fillTheWidth) { textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1)); } else { textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); } ; v = textView; } else { ImageView imgView = new TintImageView(context); imgView.setScaleType(ImageView.ScaleType.FIT_XY); imgView.setLayoutParams(new LinearLayout.LayoutParams(mTabIconSize, mTabIconSize)); v = imgView; } TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); v.setBackgroundResource(outValue.resourceId); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); v.setPadding(padding, padding, padding, padding); return v; }
From source file:com.ab.view.sliding.AbSlidingTabView2.java
/** * /* w ww .j a v a 2s . c om*/ * ??tab * @throws */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } //? Log.d(TAG, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java
private void ensureTitle() { if (!TextUtils.isEmpty(titleText) || !TextUtils.isEmpty(messageText)) { LinearLayout titleContainer = new LinearLayout(getActivity()); titleContainer.setOrientation(LinearLayout.VERTICAL); titleContainer.setGravity(Gravity.CENTER); titleContainer.setBackgroundColor(Color.WHITE); titleContainer/*from ww w.jav a2 s . c o m*/ .setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(56))); if (!TextUtils.isEmpty(titleText)) { TextView title = new TextView(getActivity()); title.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); title.setText(titleText); title.setGravity(Gravity.CENTER_HORIZONTAL); title.setTextColor(COLOR_TITLE); title.getPaint().setFakeBoldText(true); titleContainer.addView(title); } if (!TextUtils.isEmpty(messageText)) { TextView message = new TextView(getActivity()); message.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); message.setGravity(Gravity.CENTER_HORIZONTAL); message.setText(messageText); message.setTextColor(COLOR_TITLE); titleContainer.addView(message); } titleContainer.setClickable(true); titleContainer.setFocusableInTouchMode(true); sheetContainer.addView(titleContainer); sheetContainer.addView(createLine()); } }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
private TextView getPanel(String desc, LayoutParams params, int textColor) { desc = desc.trim().toUpperCase();/* w w w . ja va 2s.co m*/ final TextView panelUi = new TextView(getSherlockActivity()); panelUi.setGravity(Gravity.CENTER_HORIZONTAL); panelUi.setLayoutParams(params); panelUi.setTextColor(textColor); String prefix = (String) desc.subSequence(0, 2); prefix = prefix.trim(); try { // Start with a figure: authorized duration Integer.valueOf(prefix.trim()); panelUi.setBackgroundResource(R.drawable.bg_panel_parking); } catch (NumberFormatException e) { if (desc.subSequence(0, 1).equals("P")) { // Starts with "P " (trimmed): authorized panelUi.setBackgroundResource(R.drawable.bg_panel_parking); desc = desc.substring(1); } else if (desc.subSequence(0, 2).equals("\\A")) { panelUi.setBackgroundResource(R.drawable.bg_panel_no_stopping); desc = desc.substring(2); } else if (desc.subSequence(0, 2).equals("\\P")) { panelUi.setBackgroundResource(R.drawable.bg_panel_no_parking); desc = desc.substring(2); } else { panelUi.setBackgroundResource(R.drawable.bg_panel_no_parking); } } panelUi.setText(desc.trim()); return panelUi; }
From source file:cn.com.incito.driver.UI.detailDialog.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w ww .j a va2s . c o m tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1)); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }