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.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  a2s  .  c o m*/
            }

            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:com.yktx.check.widget.OldPagerSlidingTabStrip.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 .  j  av a 2s.c  o m
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTabTextSize);
            }
        } else if (v instanceof LinearLayout) {
            LinearLayout tab = (LinearLayout) v;
            TextView text = (TextView) tab.findViewById(R.id.text);
            text.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            text.setTypeface(tabTypeface, tabTypefaceStyle);
            text.setTextColor(tabTextColor);

            ImageView image = (ImageView) tab.findViewById(R.id.image);
            image.setImageResource(((IconTabProvider) pager.getAdapter()).getPageIconResId(i));
            // 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) {
                    text.setAllCaps(true);
                } else {
                    text.setText(text.getText().toString().toUpperCase(locale));
                }
            }

            if (i == selectedPosition) {
                text.setTextColor(selectedTabTextColor);
                text.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTabTextSize);
                image.setImageResource(((IconTabProvider) pager.getAdapter()).getSelectPageIconResId(i));
            }

        }
    }

}

From source file:net.arvin.afbaselibrary.widgets.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  ww  w . j av a2  s.  c  o  m
            }
            if (i == selectedPosition && !clear) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.haomee.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof LinearLayout) {
            v = ((LinearLayout) v).getChildAt(0);
        }/*from   ww  w. jav  a 2  s  .  c  o m*/

        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 (v instanceof ImageButton) {
            ImageButton tab = (ImageButton) v;
            if (i == currentPosition) {
                tab.setImageResource(selected_images[i]);
            } else {
                tab.setImageResource(default_images[i]);
            }
        }

    }

}

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);
            }/*  w w  w . j a  v a 2 s.c o m*/
            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.tedkim.android.tviews.slidingtab.PagerSlidingTabStrip.java

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {
            Log.d(TAG, "# updateTabStyles");

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);

            if (pager.getCurrentItem() == i) {
                tab.setTextColor(tabTextColorPressed);
            } else {
                tab.setTextColor(tabTextColor);
            }/*from  www . j a  v a2s  .com*/

            // 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:org.live.circle.component.PagerSlidingTabStrip.java

private void updateTabStyles() {
    if (tabView == null || tabView.length == 0) {
        return;/*from   www  .j  a v a2 s  .c  o m*/
    }
    for (int i = 0; i < tabView.length; i++) {
        View v = tabView[i];
        if (pager.getAdapter() != null && pager.getAdapter() instanceof CustomTabProvider) {
        } else {
            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.setSelected(i == (pager != null ? pager.getCurrentItem() : 0));
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        } else if (v instanceof ImageView) {
            ImageView tab = (ImageView) v;
            tab.setSelected(i == (pager != null ? pager.getCurrentItem() : 0));
        }
    }
}

From source file:com.shawnway.nav.app.wtw.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    //Buttonselected?
    final int count = tabsContainer.getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = tabsContainer.getChildAt(i);

        child.setSelected(selectedPosition == i);
    }//from  www  .  j  a  v  a  2 s  . c om
    //
    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);
        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);
            }
        }
    }

}

From source file:play.wm.ljb.com.wmiplay.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        if (pager.getAdapter() instanceof IconTextTabProvider) {
            ImageView tab_image = (ImageView) v.findViewById(R.id.tab_iamge);
            TextView tab_text = (TextView) v.findViewById(R.id.tab_text);

            if (mSelectPosititon == i) {
                tab_image.setImageResource(((IconTextTabProvider) pager.getAdapter()).getPageIconTextResId(i));
                tab_image.setVisibility(View.VISIBLE);
                tab_text.setVisibility(View.INVISIBLE);
            } else {
                tab_text.setText(pager.getAdapter().getPageTitle(i));
                tab_text.setVisibility(View.VISIBLE);
                tab_image.setVisibility(View.INVISIBLE);
            }/* www.j a  v  a2  s.c  o m*/
        } else if (pager.getAdapter() instanceof IconTabProvider) {
            //TODO
        } else {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);

            if (mSelectPosititon == i) {
                tab.setTextColor(XgoUIUtils.getColor(R.color.indicatorcolor));
            } else {
                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.trimph.toprand.trimphrxandroid.trimph.ui.main.news.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof RadioButton) {

            RadioButton tab = (RadioButton) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            //                tab.setTypeface(tabTypeface, tabTypefaceStyle);
            //                tab.setTextColor(getContext().getResources().getColor(R.drawable.common_tab_strip_text_selector));
            //                tab.setTextColor(Color.parseColor("#303f9f"));

            if (i == currentPosition) {
                tab.setChecked(true);/*from  w ww. ja  v a  2s. c  o m*/
            } else {
                tab.setChecked(false);
            }

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

}