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:com.cplatform.xhxw.ui.ui.base.view.PagerSlidingTabStrip.java

public void setTabTextColor(int position) {
    if (tabsContainer != null) {
        int size = tabsContainer.getChildCount();
        View v = null;// ww  w .j av  a2 s .c om
        if (position < size && cur_page < size) {
            v = tabsContainer.getChildAt(cur_page);
            if (v instanceof TextView) {
                TextView tab = (TextView) v;
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
                tab.setTextColor(tabTextColor);
            }
            v = tabsContainer.getChildAt(position);
            if (v instanceof TextView) {
                TextView tab = (TextView) v;
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTabTextSize);
                tab.setTextColor(selectTabTextColor);
            }
            cur_page = position;
        }
    }
}

From source file:cn.com.zzwfang.view.indicator.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setLayoutParams(defaultTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);//from w ww .j  a v  a 2  s .  c om
        } 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 (pager.getCurrentItem() == i) {
                tab.setTextColor(tabTextColor);
            } else {
                tab.setTextColor(tabUnselectedTextColor);
            }

            // 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.setText(tab.getText().toString().toUpperCase(locale));
            }
        }
    }

}

From source file:com.astuetz.PagerSlidingTitleIconTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof LinearLayout) {
            if (((LinearLayout) v).getChildCount() > 1) {
                v = ((LinearLayout) v).getChildAt(1);
            } else {
                v = ((LinearLayout) v).getChildAt(0);
            }//www  .  j a  v  a2  s. c o  m
        }

        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (i == currentPageSelected) {
                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 source file:cn.ieclipse.af.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        // set tabs background
        if (tabBackgroundResId > 0) {
            v.setBackgroundResource(tabBackgroundResId);
        }/*from  w w  w  . ja  v a 2s .  com*/
        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));
                }
            }
        }
    }
    setCurrentTabTextColor(selectedPosition);
}

From source file:com.example.yh.myapplication.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, unSelectTextsize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            // tab.setBackgroundColor(color);
            // 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));
                }/*ww w .  jav a2 s.com*/
            }

            if (i == selectedPosition) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTextSize);
                tab.setTextColor(selectedTextColor);
                if (roundBorder) {
                    //                        if (i == 0) {
                    //                            tab.setBackgroundResource(R.drawable.shape_food_mgr_titile_tab_left);
                    //                        } else if (i == tabCount - 1) {
                    //                            tab.setBackgroundResource(R.drawable.shape_food_mgr_titile_tab_right);
                    //                        } else {
                    //                            tab.setBackgroundResource(R.drawable.shape_food_mgr_titile_tab_middle);
                    //                        }
                }

            }
        }
    }

}

From source file:brostore.maquillage.custom.PagerSlidingTabStrip.java

private void setTextViewStyle(View v) {
    TextView tab = (TextView) v;
    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    tab.setTypeface(tabTypeface, tabTypefaceStyle);
    // TODO/* ww w.  j  a  va 2  s .  c  om*/
    //tab.setTextColor(tabTextColor);
    ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, //1
            new int[] { android.R.attr.state_selected }, //2
            new int[] {} //3
    }, new int[] { Color.WHITE, //1
            Color.WHITE, //2
            getResources().getColor(R.color.tab_text_color_unselected) //3
    });
    tab.setTextColor(colorStateList);
    tab.setTextScaleX(tabTextScaleX);

    // 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 source file:com.cube.storm.ui.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        android.view.View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(!tabSwitch ? tabBackgroundResId : transparentColorId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabSwitch && i != 0 ? tabDeactivateTextColor : 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 a  va  2  s  .  c  o m*/
            }
        } else if (v instanceof ImageButton) {
            ImageButton tab = (ImageButton) v;
            tab.setSelected(tabSwitch && i == 0 ? true : false);
        }
    }
}

From source file:cn.qbcbyb.library.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;
            if (i == currentItem) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
            } else {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            }//from  w  ww.j  av  a 2s.c  om
            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 source file:com.anniu.shandiandaojia.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;
            //TODO tab?   ????
            tab.setTextSize(TypedValue.COMPLEX_UNIT_SP, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            if (i == currentPosition) {
                tab.setTextColor(tabTextColorSelected);
            } else {
                tab.setTextColor(tabTextColor);
            }/*from  ww  w. j av  a 2s  .  c o m*/

            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 source file:com.cmax.bodysheild.widget.PagerSlidingTabStripExtends.java

/**
 * ?/*from  w w  w. ja v  a  2s  .  c o  m*/
 */
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 (mSelectedPostion == i) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}