List of usage examples for android.widget TextView setAllCaps
public void setAllCaps(boolean allCaps)
From source file:com.android.contacts.list.ContactListItemView.java
private void updateHeaderText(TextView headerTextView, String title) { setMarqueeText(headerTextView, title); headerTextView.setAllCaps(true); if (ContactsSectionIndexer.BLANK_HEADER_STRING.equals(title)) { headerTextView.setContentDescription(getContext().getString(R.string.description_no_name_header)); } else {/*from ww w .j av a 2 s . c o m*/ headerTextView.setContentDescription(title); } headerTextView.setVisibility(View.VISIBLE); }
From source file:com.it520.activity.main.wight.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. jav a 2s.c om */ protected TextView createDefaultTabView(CharSequence title) { TextView textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); textView.setText(title); textView.setTextColor(tabViewTextColors); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); if (tabViewBackgroundResId != NO_ID) { textView.setBackgroundResource(tabViewBackgroundResId); } 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(tabViewTextAllCaps); } textView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0); if (tabViewTextMinWidth > 0) { textView.setMinWidth(tabViewTextMinWidth); } return textView; }
From source file:com.shine.demo.viewpager.smartTabLayout.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)}.// w ww .j a v a2s . c o m */ protected TextView createDefaultTabView(CharSequence title) { TextView textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); textView.setText(title); textView.setTextColor(tabViewTextColors); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); if (tabViewBackgroundResId != NO_ID) { textView.setBackgroundResource(tabViewBackgroundResId); } 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(tabViewTextAllCaps); } textView.setPadding(0, tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding); if (tabViewTextMinWidth > 0) { textView.setMinHeight(tabViewTextMinWidth); } return textView; }
From source file:com.example.guxiuzhong.pagerslidingtab_lib.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { FrameLayout frameLayout = (FrameLayout) tabsContainer.getChildAt(i); frameLayout.setBackgroundResource(tabBackgroundResId); for (int j = 0; j < frameLayout.getChildCount(); j++) { View v = frameLayout.getChildAt(j); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (j == 0) { tab.setTextColor(tabTextColor); } else { tab.setTextColor(selectedTabTextColor); }/*w ww .j a v a2s . com*/ ViewHelper.setAlpha(tabViews.get(i).get("normal"), 1); ViewHelper.setAlpha(tabViews.get(i).get("selected"), 0); //set normal Scale ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f); ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f); ViewHelper.setScaleX(frameLayout, 1f); ViewHelper.setScaleY(frameLayout, 1f); // 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)); } } if (i == selectedPosition) { ViewHelper.setAlpha(tabViews.get(i).get("normal"), 0); ViewHelper.setAlpha(tabViews.get(i).get("selected"), 1); //set select Scale ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f); ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f); ViewHelper.setScaleX(frameLayout, 1 + zoomMax); ViewHelper.setScaleY(frameLayout, 1 + zoomMax); } } } } }
From source file:com.mdsgpp.cidadedemocratica.External.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w ww .jav a 2s . c om*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { tabTitleView.setTextColor(getResources().getColor(R.color.colorAccent, null)); } else { tabTitleView.setTextColor(getResources().getColor(R.color.colorAccent)); } tabTitleView.setTextSize(16); tabTitleView.setAllCaps(false); } }
From source file:com.exc.zhen.orienteering.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;// w ww . j a v a 2 s . co m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } //tabView?(my) 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); if (tabTitleView != null) { //tabTitleView.setBackgroundResource(outValue.resourceId); tabTitleView.setBackgroundResource(R.drawable.tab_color); } } //tabView?(my) 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 if (tabTitleView != null) { tabTitleView.setAllCaps(true); } } if (tabTitleView != null) { tabTitleView.setText(adapter.getPageTitle(i)); } tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.minnloft.checkmyfluids.tabs.SlidingTabLayout.java
private void populateTabStrip() { final ViewPagerAdapter adapter = (ViewPagerAdapter) mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from w w w . java 2 s .c om TextView tabTitleView = null; ImageView tabImageView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); tabImageView = (ImageView) tabView.findViewById(mTabViewImageId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (tabImageView == null && ImageView.class.isInstance(tabView)) { tabImageView = (ImageView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); //tabImageView.setImageResource(adapter.getImageId(i)); tabImageView.setImageDrawable(getResources().getDrawable(adapter.getImageId(i))); if (mViewPager.getCurrentItem() == i) { tabImageView.setSelected(true); } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); //Change the font size tabTitleView.setTextSize(TAB_TEXT_SIZE); tabTitleView.setAllCaps(true); } }
From source file:com.zitech.framework.widget.SlidingTabs.java
/** * call this function if you call some setXXX() function */// www . j a va2 s . co m private void updateTabStyles() { PagerAdapter adapter = this.pager.getAdapter(); if (adapter instanceof TabsTitleInterface) { for (int i = 0; i < this.tabCount; i++) { View v = this.tabsContainer.getChildAt(i); v.setBackgroundResource(this.tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; SpannableString spannableString = ((TabsTitleInterface) adapter).getTabTitle(i); if (i == this.selectedPosition) { spannableString.setSpan(new ForegroundColorSpan(this.selectedTabTextColor), 0, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); tab.setText(spannableString); } else { spannableString.setSpan(new ForegroundColorSpan(this.tabTextColor), 0, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); tab.setText(spannableString); } } } } else { for (int i = 0; i < this.tabCount; i++) { View v = this.tabsContainer.getChildAt(i); v.setBackgroundResource(this.tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, tabTextSize); tab.setTypeface(this.tabTypeface, this.tabTypefaceStyle); tab.setTextColor(this.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)); } } if (i == this.selectedPosition) { tab.setTextColor(this.selectedTabTextColor); } else { tab.setTextColor(this.tabTextColor); } } } } }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
private View makeView(boolean icon, boolean watcher, boolean closeable, float density) { int size = (int) (48f * density); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); ImageView iconView = null;/*from www. j a v a 2s . com*/ if (icon) { iconView = new ImageView(context); iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); linearLayout.addView(iconView, (int) (24f * density), size); } TextView textView = makeCommonTextView(false); linearLayout.addView(textView, new LinearLayout.LayoutParams(0, size, 1)); WatcherView watcherView = null; if (watcher) { watcherView = new WatcherView(context); linearLayout.addView(watcherView, size, size); } ImageView closeView = null; if (!watcher && closeable) { closeView = new ImageView(context); closeView.setScaleType(ImageView.ScaleType.CENTER); closeView.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonCancel, 0)); closeView.setBackgroundResource(ResourceUtils.getResourceId(context, android.R.attr.borderlessButtonStyle, android.R.attr.background, 0)); linearLayout.addView(closeView, size, size); closeView.setOnClickListener(closeButtonListener); } ViewHolder holder = new ViewHolder(); holder.icon = iconView; holder.text = textView; holder.extra = watcherView != null ? watcherView : closeView; linearLayout.setTag(holder); int layoutLeftDp = 0; int layoutRightDp = 0; int textLeftDp; int textRightDp; if (C.API_LOLLIPOP) { textLeftDp = 16; textRightDp = 16; if (icon) { layoutLeftDp = 16; textLeftDp = 32; } if (watcher || closeable) { layoutRightDp = 4; textRightDp = 8; } } else { textLeftDp = 8; textRightDp = 8; if (icon) { layoutLeftDp = 8; textLeftDp = 6; textView.setAllCaps(true); } if (watcher || closeable) { layoutRightDp = 0; textRightDp = 0; } } linearLayout.setPadding((int) (layoutLeftDp * density), 0, (int) (layoutRightDp * density), 0); textView.setPadding((int) (textLeftDp * density), 0, (int) (textRightDp * density), 0); return linearLayout; }