List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:com.astuetz.PagerSlidingTabStripMenu.java
private void addIconTab2(final int position, String title, int resId) { TextView tab = new TextView(getContext()); tab.setText(title);/*www . ja v a2 s . co m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setCompoundDrawablePadding(mTabDrawablePadding); switch (mIconPostion) { case Left: tab.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0); break; case Top: tab.setCompoundDrawablesWithIntrinsicBounds(0, resId, 0, 0); break; case Right: tab.setCompoundDrawablesWithIntrinsicBounds(0, 0, resId, 0); break; case Bottom: tab.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, resId); break; } addTab(position, tab); }
From source file:cn.hollo.www.custom_view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title, int leftIcon) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w . j a va 2s .com tab.setGravity(Gravity.CENTER); tab.setSingleLine(); if (tabTextColor != null) tab.setTextColor(tabTextColor); else tab.setTextColor(defaultTabTextColor); tab.setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, 0, 0); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); addTab(position, tab); }
From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java
private static void addImgLinkText(final Context context, ArrayList<View> views, final String url, LinearLayout.LayoutParams params) { final TextView textView = new TextView(context); textView.setTextColor(Color.BLUE); textView.setLayoutParams(params);/*w w w.j a v a2s .c o m*/ textView.setText("View image"); textView.setTextSize(getTextSize(context)); textView.setPadding(3, 3, 3, 3); textView.setTag(url); textView.setClickable(true); setupOnLinkClick(context, url, textView); views.add(textView); }
From source file:com.googlecode.android_scripting.activity.Main.java
protected void initializeViews() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER_HORIZONTAL); TextView textview = new TextView(this); textview.setText(" PhpForAndroid " + version); ImageView imageView = new ImageView(this); imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa)); layout.addView(imageView);//from w w w . j ava 2s . c o m mButton = new Button(this); mAboutButton = new Button(this); MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final float scale = getResources().getDisplayMetrics().density; int marginPixels = (int) (MARGIN_DIP * scale + 0.5f); marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels); mButton.setLayoutParams(marginParams); mAboutButton.setLayoutParams(marginParams); layout.addView(textview); layout.addView(mButton); layout.addView(mAboutButton); mProgressLayout = new LinearLayout(this); mProgressLayout.setOrientation(LinearLayout.HORIZONTAL); mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); LinearLayout bottom = new LinearLayout(this); bottom.setOrientation(LinearLayout.HORIZONTAL); bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.setGravity(Gravity.CENTER_VERTICAL); mProgressLayout.addView(bottom); TextView message = new TextView(this); message.setText(" In Progress..."); message.setTextSize(20); message.setTypeface(Typeface.DEFAULT_BOLD); message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); ProgressBar bar = new ProgressBar(this); bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.addView(bar); bottom.addView(message); mProgressLayout.setVisibility(View.INVISIBLE); layout.addView(mProgressLayout); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(false); setContentView(layout); }
From source file:com.ch.ch_library.smartlayout.SmartTabLayout.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 w ww. j ava2 s. co m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(mTabViewTextColor); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabViewTextSize); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(mTabViewTextAllCaps); } textView.setPadding(mTabViewTextHorizontalPadding, 0, mTabViewTextHorizontalPadding, 0); if (mTabViewTextMinWidth > 0) { textView.setMinWidth(mTabViewTextMinWidth); } return textView; }
From source file:com.cc.custom.uikit.PagerSlidingTabStrip.java
private void addTextTab(final int position, CharSequence title) { TextView tab = new TextView(getContext()); tab.setText(title);/* w ww. j a v a 2 s. c o m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE TEXT ROW/* ww w . ja v a 2 s . c o m*/ * @param att * @param linear * @return */ public LinearLayout getSingleTextRow(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, LayoutParams.WRAP_CONTENT, 0.5f); TextView t2 = new TextView(context); t2.setText(att.get("value").equals("") ? " - " : att.get("value")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t2, value_params); linear.addView(container_layout); return linear; }
From source file:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java
private TextView getLabelTextView(RelativeLayout widgetView, OpenHABWidget openHABWidget) { // Get TextView for widget label and set it's color Integer labelColor = openHABWidget.getLabelColor(); TextView labelTextView = (TextView) widgetView.findViewById(R.id.widgetlabel); if (labelColor != null && labelTextView != null) { Log.d(HABApplication.getLogTag(), String.format("Setting label color to %d", labelColor)); labelTextView.setTextColor(labelColor); } else if (labelTextView != null) { TextView defaultTextView = new TextView(widgetView.getContext()); labelTextView.setTextColor(defaultTextView.getTextColors().getDefaultColor()); }// w w w . j ava 2 s . c o m return labelTextView; }
From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java
/** add one text tab */ private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* w w w. jav a 2 s.c o m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.csdn.pagerslidingtabstrip.view.PagerSlidingTabStrip.java
private void addTextTab2(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w w w. ja v a2 s.c om*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab2(position, tab); }