Example usage for android.util TypedValue COMPLEX_UNIT_PX

List of usage examples for android.util TypedValue COMPLEX_UNIT_PX

Introduction

In this page you can find the example usage for android.util TypedValue COMPLEX_UNIT_PX.

Prototype

int COMPLEX_UNIT_PX

To view the source code for android.util TypedValue COMPLEX_UNIT_PX.

Click Source Link

Document

#TYPE_DIMENSION complex unit: Value is raw pixels.

Usage

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);
            }//from   ww w  .  j  a v a  2  s  .com
        }
    }

}

From source file:com.runApp.ui.utils.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        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));
                }//w  w w .  java 2s.  c  o  m
            }
        } else if (v instanceof ImageButton) {
            ImageButton tab = (ImageButton) v;
            tab.setSelected(tabSwitch && i == 0 ? true : false);

        }

    }
}

From source file:com.example.moses.mosesnews.utils.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);
            if (i == 0) {
                tab.setTextColor(getResources().getColor(android.R.color.holo_green_dark));
            } else {
                tab.setTextColor(tabTextColor);
            }//from   w ww  .  j a  v a  2  s  .  c  o m

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

}

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

            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  ww. java 2  s  .  co  m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.astuetz.PagerSlidingTrilateralStrip.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);
            //?item,,??
            /*add by HJ begin ??*/
            if (pager.getCurrentItem() == i) {
                //
                tab.setTextColor(tabSelectedTextColor);
            } else {
                //?
                tab.setTextColor(tabNormalTextColor);
            }/*from w  ww. j a  va2s.  c  om*/
            /*add by HJ end ??*/
            // 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:za.jamie.soundstage.widgets.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        TextView tab = (TextView) tabsContainer.getChildAt(i);

        tab.setLayoutParams(defaultTabLayoutParams);
        tab.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            tab.setPadding(0, 0, 0, 0);/*from w  w  w  .ja va 2s.c o m*/
        } else {
            tab.setPadding(tabPadding, 0, tabPadding, 0);
        }

        tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        tab.setTypeface(tabTypeface, tabStyleIndex);
        tab.setTextColor(tabTextColor);

        if (textAllCaps) {
            tab.setAllCaps(true);
        }
    }
}

From source file:com.unkonw.testapp.libs.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);// w  w  w . j ava2s  .  c o m
        } 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 == 0) {
                tab.setTextSize(14);
                selectedBackground(tab);
                tab.setTextColor(getResources().getColor(indexColor));
            }

            else {
                tab.setBackgroundColor(backGroundColor);
                tab.setTextColor(tabTextColor);
                tab.setTextSize(tabTextSize);
            }

            // 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.hollo.www.custom_view.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    TextView tab = new TextView(getContext());
    tab.setText(title);//w  ww .  j ava 2 s  .c  om
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    if (tabTextColor != null)
        tab.setTextColor(tabTextColor);
    else
        tab.setTextColor(defaultTabTextColor);

    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    addTab(position, tab);
}

From source file:com.lean56.andplug.app.view.WechatTab.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   www . ja  va  2  s. c o  m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}