android.widget.TextView#setAllCaps ( )源码实例Demo

下面列出了android.widget.TextView#setAllCaps ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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;
}
 
/**
 * 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;
}
 
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));
                }
            }
        }
    }
}
 
源代码4 项目: PADListener   文件: 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)}.
 */
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;
}
 
源代码5 项目: ExpressHelper   文件: 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)}.
 */
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;
}
 
源代码6 项目: Bright   文件: 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)}.
 */
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;
}
 
源代码7 项目: android-sliderview   文件: SlidingTabLayout.java
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;
}
 
源代码8 项目: giffun   文件: 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);
				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);
				}
			}
		}

	}
 
源代码9 项目: SpinningTabStrip   文件: SpinningTabStrip.java
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));
                }
            }
        }
    }

}
 
源代码10 项目: Noyze   文件: PreferenceColorCategory.java
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView titleView = (TextView) view.findViewById(android.R.id.title);
    titleView.setAllCaps(allCaps);
    titleView.setTextColor(titleColor);
}
 
源代码11 项目: 920-text-editor-v2   文件: PagerSlidingTabStrip.java
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));
                    }
                }
            }
        }

    }
 
源代码12 项目: SuperToasts   文件: TabStrip.java
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);
    }
 
源代码13 项目: NoboButton   文件: NoboButton_2.java
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());


}
 
源代码14 项目: Noyze   文件: PreferenceColorCategory.java
@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView titleView = (TextView) view.findViewById(android.R.id.title);
    titleView.setAllCaps(allCaps);
    titleView.setTextColor(titleColor);
}
 
源代码15 项目: SmartChart   文件: 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)}.
 */
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;
}
 
源代码16 项目: UltimateAndroid   文件: 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);
				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));
					}
				}
			}
		}

	}
 
源代码17 项目: school_shop   文件: 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);
				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);
				}
			}
		}

	}
 
源代码18 项目: actor-platform   文件: 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);
                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);

            }
        }

    }
 
/**
 * 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);
  }
}
 
源代码20 项目: iGap-Android   文件: ViewMaker.java
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;
    }
 
 方法所在类
 同类方法