List of usage examples for android.widget TextView setTextSize
public void setTextSize(int unit, float size)
From source file:com.bhatworks.android.slidingtab.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 w w. ja v a2 s.co m */ 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); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); 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); if (mTabColor != null) { textView.setTextColor(mTabColor); } return textView; }
From source file:com.agenthun.readingroutine.utils.TextSharedElementCallback.java
@Override public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { TextView targetView = getTextView(sharedElements); if (targetView == null) { Log.w(TAG, "onSharedElementStart: No shared TextView, skipping."); return;// w ww .jav a2 s .c om } mTargetViewTextSize = targetView.getTextSize(); mTargetViewPaddingStart = targetView.getPaddingStart(); // Setup the TextView's start values. targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mInitialTextSize); ViewUtils.setPaddingStart(targetView, mInitialPaddingStart); }
From source file:audio.lisn.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)}./* www . ja v a 2 s. c om*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.WHITE); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); 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(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.crazy.toutiaonews.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 w w. ja v a2 s . c o m*/ */ 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); // Holo ?? // 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(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.chalmers.schmaps.CheckBusActivity.java
/** * Makes the rows for the chalmerstable//from w w w . j a va 2 s . c o m */ public void makeChalmersRows() { for (int i = 0; i < NROFROWS; i++) { TableRow tempTableRow = new TableRow(this); tempTableRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // Makes every other row light gray or white if (i % 2 == 0) { tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_grey)); } else { tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_white)); } //Makes every textview for each column and add it before starting with a new one for (int j = 0; j < NR_OF_COLUMNS; j++) { TextView textview = new TextView(this); textview.setTextColor(Color.BLACK); textview.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE); //Check which content should be written in the textview if (j == COLUMN_NR_1) { textview.setText(chalmersLineArray.get(i)); } else if (j == COLUMN_NR_2) { textview.setText(chalmersDestArray.get(i)); } else if (j == COLUMN_NR_3) { textview.setText(chalmersTimeArray.get(i)); } else if (j == COLUMN_NR_4) { textview.setText(chalmersTrackArray.get(i)); } textview.setGravity(Gravity.CENTER_HORIZONTAL); tempTableRow.addView(textview); } chalmersTable.addView(tempTableRow, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } }
From source file:com.chalmers.schmaps.CheckBusActivity.java
/** * Makes the rows for the lindholmentable *///www .j a v a 2s .c om public void makeLindholmenRows() { for (int i = 0; i < NROFROWS; i++) { TableRow tempTableRow = new TableRow(this); tempTableRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // Makes every other row light gray or white if (i % 2 == 0) { tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_grey)); } else { tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_white)); } //Makes every textview for each column and add it before starting with a new one for (int j = 0; j < NR_OF_COLUMNS; j++) { TextView textview = new TextView(this); textview.setTextColor(Color.BLACK); textview.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE); //Check which content should be written in the textview if (j == COLUMN_NR_1) { textview.setText(lindholmenLineArray.get(i)); } else if (j == COLUMN_NR_2) { textview.setText(lindholmenDestArray.get(i)); } else if (j == COLUMN_NR_3) { textview.setText(lindholmenTimeArray.get(i)); } else if (j == COLUMN_NR_4) { textview.setText(lindholmenTrackArray.get(i)); } textview.setGravity(Gravity.CENTER_HORIZONTAL); tempTableRow.addView(textview); } lindholmenTable.addView(tempTableRow, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } }
From source file:com.autogermany.opel360.Utils.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)}./*ww w . j av a2 s . c om*/ */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.parseColor("#FFFFFF")); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); 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(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.bryan.example.widget.slidingtablayout.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 w ww. j a v a2 s .c om*/ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { /** * ?Holo?? */ 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);// textView.setTypeface(Typeface.DEFAULT); // 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(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.development.jaba.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 w w w . ja v a 2 s.co m */ 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); // By default use the unselected title color. textView.setTextColor(mTitleColor); 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(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
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 .ja v a 2s . c om */ 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; }