Java Code Examples for android.widget.TextView#setAllCaps()

The following examples show how to use android.widget.TextView#setAllCaps() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlidingTabLayout.java    From android-SwipeRefreshListFragment with Apache License 2.0 6 votes vote down vote up
/**
 * 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)}.
 */
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);

    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;
}
 
Example 2
Source File: SlidingTabLayout.java    From Bright with Apache License 2.0 6 votes vote down vote up
/**
 * 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)}.
 */
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);

    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;
}
 
Example 3
Source File: SlidingTabLayout.java    From ExpressHelper with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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)}.
 */
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);

	return textView;
}
 
Example 4
Source File: SlidingTabLayout.java    From PADListener with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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)}.
 */
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);

	return textView;
}
 
Example 5
Source File: PagerSlidingTabStrip.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
            // 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));
                }
            }
        }
    }
}
 
Example 6
Source File: SlidingTabLayout.java    From android-SlidingTabsBasic with Apache License 2.0 6 votes vote down vote up
/**
 * 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)}.
 */
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);

    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;
}
 
Example 7
Source File: PagerSlidingTabStrip.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
private void updateTabStyles() {

        for (int i = 0; i < tabCount; i++) {

            View v = tabsContainer.getChildAt(i);

            if(tabBackgroundResId > 0)
                v.setBackgroundResource(tabBackgroundResId);

            if (v instanceof 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));
                    }
                }
            }
        }

    }
 
Example 8
Source File: TabStrip.java    From SuperToasts with Apache License 2.0 5 votes vote down vote up
private void addTextTab(final int position, String title) {

        TextView tab = new TextView(getContext());
        tab.setText(title);
        tab.setGravity(Gravity.CENTER);
        tab.setSingleLine();
        tab.setAllCaps(true);

        addTab(position, tab);
    }
 
Example 9
Source File: NoboButton_2.java    From NoboButton with Apache License 2.0 5 votes vote down vote up
private void setupTextView() {
	textView = new TextView(context);
	/*LayoutParams textViewParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	textView.setLayoutParams(textViewParams);*/

	/*if (text == null || text.isEmpty()) {
		text = "";
		return;
	}*/

	textView.setText(text);
	textView.setTextColor(isEnabled ? textColor : disabledTextColor);
	textView.setTextSize(pxToSp(context, textSize));
	textView.setAllCaps(textAllCaps);

	// font style normal, bold, italic
	if (textStyle == 2) {
		textView.setTypeface(textView.getTypeface(), Typeface.ITALIC);
	} else if (textStyle == 1) {
		textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
	} else {
		textView.setTypeface(textView.getTypeface(), Typeface.NORMAL);
	}

	//textView.setEnabled(isEnabled());


}
 
Example 10
Source File: PreferenceColorCategory.java    From Noyze with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView titleView = (TextView) view.findViewById(android.R.id.title);
    titleView.setAllCaps(allCaps);
    titleView.setTextColor(titleColor);
}
 
Example 11
Source File: SlidingTabLayout.java    From android-sliderview with MIT License 5 votes vote down vote up
private View getDefaultTabView(CharSequence title) {
    int padding = (int) (DEFAULT_TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    if (textColor == -1) textColor = defaultTextColor;

    TextView tab = new TextView(getContext());
    tab.setGravity(Gravity.CENTER);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    tab.setTypeface(Typeface.DEFAULT_BOLD);
    tab.setTextColor(textColor);
    tab.setAllCaps(true);
    tab.setText(title);
    tab.setPadding(padding, padding, padding, padding);
    return tab;
}
 
Example 12
Source File: SmartTabLayout.java    From SmartChart with Apache License 2.0 5 votes vote down vote up
/**
 * 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)}.
 */
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;
}
 
Example 13
Source File: PreferenceColorCategory.java    From Noyze with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView titleView = (TextView) view.findViewById(android.R.id.title);
    titleView.setAllCaps(allCaps);
    titleView.setTextColor(titleColor);
}
 
Example 14
Source File: PagerSlidingTabStrip.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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);
				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));
					}
				}
			}
		}

	}
 
Example 15
Source File: SpinningTabStrip.java    From SpinningTabStrip with Apache License 2.0 5 votes vote down vote up
private void updateTabStyles() {
    for (int i = 0; i < realTabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        if (!(pager.getAdapter() instanceof CustomTabProvider)) {
            v.setBackgroundResource(tabBackgroundResId);
        }
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());

        TextView tabTitle = (TextView) v.findViewById(R.id.tab_title);
        if (tabTitle != null) {
            tabTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tabTitle.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tabTitle.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) {
                    tabTitle.setAllCaps(true);
                } else {
                    tabTitle.setText(tabTitle.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}
 
Example 16
Source File: PagerSlidingTabStrip.java    From giffun with Apache License 2.0 5 votes vote down vote up
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);
				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));
					}
				}
				if (i == selectedPosition) {
					tab.setTextColor(selectedTabTextColor);
				}
			}
		}

	}
 
Example 17
Source File: PagerSlidingTabStrip.java    From school_shop with MIT License 5 votes vote down vote up
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);
				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));
					}
				}
				if (i == selectedPosition) {
					tab.setTextColor(selectedTabTextColor);
				}
			}
		}

	}
 
Example 18
Source File: PagerSlidingTabStrip.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
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);
                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
                tab.setAllCaps(true);

            }
        }

    }
 
Example 19
Source File: IceCreamSandwichUtil.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the font face of {@code view} to all caps (true) or regular (false).
 * @param view the text view to update
 * @param allCaps true for all caps, false otherwise
 */
public static void setAllCaps(TextView view, boolean allCaps) {
  if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
    view.setAllCaps(allCaps);
  }
}
 
Example 20
Source File: ViewMaker.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
static View getTimeItem() {

        LinearLayout linearLayout_33 = new LinearLayout(G.context);
        linearLayout_33.setOrientation(HORIZONTAL);
        linearLayout_33.setGravity(CENTER);
        LinearLayout.LayoutParams layout_509 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        linearLayout_33.setLayoutParams(layout_509);
        linearLayout_33.setPadding(0, i_Dp(R.dimen.dp12), 0, i_Dp(R.dimen.dp12));

        View view_12 = new View(G.context);
        view_12.setBackgroundColor(Color.parseColor(G.logLineTheme));
        LinearLayout.LayoutParams layout_522 = new LinearLayout.LayoutParams(0, 1, 1);
        view_12.setLayoutParams(layout_522);
        linearLayout_33.addView(view_12);

        TextView text = new TextView(G.context);
        text.setId(R.id.cslt_txt_time_date);
        text.setSingleLine(true);
        text.setPadding(i_Dp(R.dimen.dp16), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp16), i_Dp(R.dimen.dp4));
        if (isDarkTheme) {
            text.setBackgroundResource(R.drawable.background_log_time_dark);
            text.setTextColor(Color.parseColor(G.textSubTheme));
        } else {
            text.setBackgroundResource(R.drawable.background_log_time);
            text.setTextColor(G.context.getResources().getColor(R.color.text_log_time));
        }

        text.setText("Today");
        text.setAllCaps(false);
        setTextSize(text, R.dimen.dp12);
        setTypeFace(text);
        LinearLayout.LayoutParams layout_835 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layout_835.gravity = Gravity.CENTER_HORIZONTAL;
        text.setLayoutParams(layout_835);
        linearLayout_33.addView(text);

        View vew_147 = new View(G.context);
        vew_147.setBackgroundColor(Color.parseColor(G.logLineTheme));
        LinearLayout.LayoutParams layout_270 = new LinearLayout.LayoutParams(0, 1, 1);
        vew_147.setLayoutParams(layout_270);
        linearLayout_33.addView(vew_147);

        return linearLayout_33;
    }