Example usage for android.widget TextView setAllCaps

List of usage examples for android.widget TextView setAllCaps

Introduction

In this page you can find the example usage for android.widget TextView setAllCaps.

Prototype

public void setAllCaps(boolean allCaps) 

Source Link

Document

Sets the properties of this field to transform input to ALL CAPS display.

Usage

From source file:com.stevenschoen.putionew.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  va  2 s .co m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setTextColor(context.getResources().getColor(android.R.color.black));
    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.MATCH_PARENT));

    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;
}

From source file:co.ronash.pushesample.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 . jav  a  2  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);
    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);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        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.dianxun.holyn.lucky.view.widget.ViewpagerHeaderScroll.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set
 * via/* w  w w  .  j  av  a 2 s  .com*/
 * {@link #setCustomTabView(int, int)}.
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(getResources().getColor(R.color.black));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    //        textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f));

    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(0, padding, 0, padding);

    return textView;
}

From source file:com.payu.payuui.Widget.SwipeTab.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 a v  a  2 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);
    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);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
        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.pax.view.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) {
                tab.setAllCaps(true);
            }// w  w  w.j a  v  a 2  s .c om
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.android.contacts.list.MultiSelectContactsListFragment.java

/**
 * Show account icon, count of contacts and account name in the header of the list.
 *//*from w w  w.ja  v  a 2 s .  co m*/
protected void bindListHeader(Context context, View listView, View accountFilterContainer,
        AccountWithDataSet accountWithDataSet, int memberCount) {
    if (memberCount < 0) {
        hideHeaderAndAddPadding(context, listView, accountFilterContainer);
        return;
    }

    bindListHeaderCommon(listView, accountFilterContainer);

    final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(context);
    final AccountType accountType = accountTypeManager.getAccountType(accountWithDataSet.type,
            accountWithDataSet.dataSet);

    // Set text of count of contacts and account name
    final TextView accountFilterHeader = (TextView) accountFilterContainer
            .findViewById(R.id.account_filter_header);
    final String headerText = shouldShowAccountName(accountType)
            ? String.format(context.getResources().getQuantityString(R.plurals.contacts_count_with_account,
                    memberCount), memberCount, accountWithDataSet.name)
            : context.getResources().getQuantityString(R.plurals.contacts_count, memberCount, memberCount);
    accountFilterHeader.setText(headerText);
    accountFilterHeader.setAllCaps(false);

    // Set icon of the account
    final Drawable icon = accountType != null ? accountType.getDisplayIcon(context) : null;
    final ImageView accountFilterHeaderIcon = (ImageView) accountFilterContainer
            .findViewById(R.id.account_filter_icon);

    // If it's a writable Google account, we set icon size as 24dp; otherwise, we set it as
    // 20dp. And we need to change margin accordingly. This is because the Google icon looks
    // smaller when the icons are of the same size.
    if (accountType instanceof GoogleAccountType) {
        accountFilterHeaderIcon.getLayoutParams().height = getResources()
                .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size);
        accountFilterHeaderIcon.getLayoutParams().width = getResources()
                .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size);

        setMargins(accountFilterHeaderIcon,
                getResources().getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_left_margin),
                getResources().getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_right_margin));
    } else {
        accountFilterHeaderIcon.getLayoutParams().height = getResources()
                .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size_alt);
        accountFilterHeaderIcon.getLayoutParams().width = getResources()
                .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size_alt);

        setMargins(accountFilterHeaderIcon,
                getResources()
                        .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_left_margin_alt),
                getResources()
                        .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_right_margin_alt));
    }
    accountFilterHeaderIcon.requestLayout();

    accountFilterHeaderIcon.setVisibility(View.VISIBLE);
    accountFilterHeaderIcon.setImageDrawable(icon);
}

From source file:com.example.rodri.vocabbuilder.tabs.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 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);
    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);
    // Need to set it as false in order to use images instead of titles in the Tab Layout
    textView.setAllCaps(false);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:dev.jinkim.snappollandroid.ui.widget.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)}./*from  w  ww. j a  v  a  2 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.setTextColor(getResources().getColor(R.color.text_slidingtab_title_active));
    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;
}

From source file:com.contentful.discovery.ui.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.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));
                }// w  w w .  j av  a  2  s .  c o m
            }
        }
    }
}

From source file:com.toycantando.pollitos.tablayout.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 va  2s  .com
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(getResources().getColor(R.color.tabstext));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.tabstext_size));
    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;
}