Example usage for android.widget TextView setTextSize

List of usage examples for android.widget TextView setTextSize

Introduction

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

Prototype

public void setTextSize(int unit, float size) 

Source Link

Document

Set the default text size to a given unit and value.

Usage

From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        //            v.setBackgroundDrawable(tabBackgroundDrawable);

        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            if (i == 0)
                tab.setTextColor(tabchecktextcolor);

            // 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  a  v a 2  s  .com
            }
        }
    }

}

From source file:com.example.appdetail_optimization.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);

            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }/* www .  java  2s.  co m*/
        }
    }

}

From source file:cn.qbcbyb.library.view.PagerSlidingTabStrip.java

public void setCurrentItem(int currentItem) {
    if (this.currentItem > -1 && this.currentItem < tabsContainer.getChildCount()) {
        View view = tabsContainer.getChildAt(this.currentItem);
        view.setSelected(false);/*w  ww  . j  av a2  s .c o  m*/
        if (view instanceof TextView) {
            TextView tab = ((TextView) view);
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        }
    }
    this.currentItem = currentItem;
    if (this.currentItem > -1 && this.currentItem < tabsContainer.getChildCount()) {
        View view = tabsContainer.getChildAt(this.currentItem);
        view.setSelected(true);
        if (view instanceof TextView) {
            TextView tab = ((TextView) view);
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
        }
    }
}

From source file:com.android.mms.rcs.FavoriteDetailAdapter.java

private void initTextMsgView(final TextView bodyText) {
    bodyText.setText(// www . j  a  va2s. co m
            mCursor.getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CONTENT)));
    bodyText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mBodyFontSize);
    bodyText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    bodyText.setTextIsSelectable(true);
    bodyText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MessageUtils.onMessageContentClick(mContext, bodyText);
        }
    });
}

From source file:com.cyntwikip.android.phirelert.FireFeed.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 av a  2 s. c  om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);

    /* Edited Part */
    //for Fonts
    //Typeface face = Typeface.createFromAsset(context.getAssets(), "font/Roboto-Light.ttf");
    //textView.setTypeface(face);
    textView.setTypeface(Typeface.SANS_SERIF);

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

From source file:com.android.app.buystoreapp.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));
                }/*from w  w w. j ava  2s  . co m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
            }
        }
    }

}

From source file:com.anjuke.library.uicomponent.slidingtab.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);
        if (shouldExpand) {
            v.setLayoutParams(expandedTabLayoutParams);
        } else {//from w w w  .j  av a  2 s .c  o  m
            v.setLayoutParams(defaultTabLayoutParams);
        }
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);
        } 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 == pager.getCurrentItem() && selectedTextColor != 0) {
                tab.setTextColor(selectedTextColor);// add by TomkeyZhang
            } else {
                tab.setTextColor(tabTextColor);
            }
        }

    }

}

From source file:com.astuetz.PagerSlidingTabStripExtend.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));
                }/*  w w w.java2  s . c o  m*/
            }

            //??
            if (i == mSelectedIndex) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
                tab.setTextColor(tabSelectedTextColor);
            }
        }
    }

}

From source file:com.dashihui.afford.ui.widget.WdtPagerSlidingTabStrip.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));
                }//w  ww  .j ava 2  s .  c o m
            }
        }
    }

}

From source file:com.example.wechatsample.utils.widget.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);
            //?tab
            tab.setBackgroundResource(R.drawable.background_tab);
            //            tab.setTextColor(R.drawable.tabtextcolor_selector);

            // 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  ww .j a v a  2s  .  c  o m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setBackgroundResource(0);
            }
        }
    }

}