List of usage examples for android.widget TextView setAllCaps
public void setAllCaps(boolean allCaps)
From source file:com.supermonkey.lifeassistant.view.pager.PagerSlidingTabStrip.java
/** * tab?/* w ww . j ava 2 s . com*/ */ private void updateTabStyles() { // tab for (int i = 0; i < tabCount; i++) { // ?? View v = tabsContainer.getChildAt(i); // v.setBackgroundResource(tabBackgroundResId); // ?TextView if (v instanceof TextView) { // TextView TextView tab = (TextView) v; // tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); // ? tab.setTypeface(tabTypeface, tabTypefaceStyle); // tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }
From source file:com.ghkjgod.lightnovel.component.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom()); TextView tab_title = (TextView) v.findViewById(R.id.tab_title); if (tab_title != null) { tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle); if (tabTextColor != null) { tab_title.setTextColor(tabTextColor); }//from w ww . java 2 s. co m // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab_title.setAllCaps(true); } else { tab_title.setText(tab_title.getText().toString().toUpperCase(locale)); } } } } }
From source file:com.jei.widgettest.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)}.// w ww . j a 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); // Weight ?? . WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mViewPager.getAdapter().getCount()); 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.mickledeals.views.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 . java 2 s . com*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimensionPixelSize(R.dimen.sp_17)); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(Color.argb((int) (MIN_TEXT_ALPHA * 255), 255, 255, 255)); textView.setBackgroundResource(R.drawable.selector_bg); // 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.dtd.thevyshka.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)}.//from w w w . j a v a2 s. co m */ @SuppressLint("NewApi") protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mTabCount); textView.setGravity(Gravity.CENTER); textView.setTextSize(12);//TODO adapting to all textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(ContextCompat.getColor(context, R.color.white)); 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 / 2, padding, padding / 2, padding); return textView; }
From source file:com.freud.mrzz.views.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom()); TextView tab_title = (TextView) v.findViewById(R.id.tv_tab_title); if (tab_title != null) { tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle); if (tabTextColor != null) { tab_title.setTextColor(tabTextColor); }//from w ww. j av a 2 s .co m // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab_title.setAllCaps(true); } else { tab_title.setText(tab_title.getText().toString().toUpperCase(locale)); } } } } }
From source file:com.keertech.androidnotes.view.tabview.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.j av a2 s .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); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); if (mTabViewTextBackgroundId > 0) { textView.setBackgroundResource(mTabViewTextBackgroundId); } else { 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.bwash.bwashcar.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (pager.getAdapter() instanceof IconTabProvider) { TextView tab = (TextView) v.findViewById(R.id.text); tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(((IconTabProvider) pager.getAdapter()).getPageTextColor(i)); tab.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(((IconTabProvider) pager.getAdapter()).getPageIconResId(i)), null, null, null);//from w w w . j a v a2s.c o m // tab.setBackgroundDrawable(getResources().getDrawable(((IconTabProvider)pager.getAdapter()).getPageIconResId(i))); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } else { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(0xffffffff); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }
From source file:com.mugu.mp3prayer.utils.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (tabTextColorStateListId != -1) { ColorStateList cs = getResources().getColorStateList(tabTextColorStateListId); tab.setTextColor(cs);//w ww .ja va2 s. c o m } else { tab.setTextColor(tabTextColor); } // setAllCaps() is only available from API 14, so the upper case // is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } /* zhaobinbin */ if (tabTextColorOnSelected != -1) { updateTextColorOnSelected(currentPosition); } /* zhaobinbin */ }
From source file:com.unkonw.testapp.libs.view.indicator.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setLayoutParams(defaultTabLayoutParams); v.setBackgroundResource(tabBackgroundResId); if (shouldExpand) { v.setPadding(0, 0, 0, 0);//from w w w . jav a 2 s .c o m } else { v.setPadding(tabPadding, 0, tabPadding, 0); } if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (i == 0) { tab.setTextSize(14); selectedBackground(tab); tab.setTextColor(getResources().getColor(indexColor)); } else { tab.setBackgroundColor(backGroundColor); tab.setTextColor(tabTextColor); tab.setTextSize(tabTextSize); } // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }