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.icoder.couldnewsclient.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);
            if (tab == selectedTabText)
                tab.setTextColor(tabTextSelectedColor);
            else/*from  w  w  w .j  a v  a2 s  .co m*/
                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));
                }
            }
        }
    }

    invalidate();
}

From source file:com.cloudTop.starshare.ui.wangyi.common.ui.viewpager.PagerSlidingTabStrip.java

private void addTabView(final int position, String title) {
    View tabView = null;//  w w  w.  j  a  v  a  2  s .co  m
    boolean screenAdaptation = false;
    final LayoutInflater inflater = LayoutInflater.from(getContext());
    if (this.onCustomTabListener != null) {
        int tabResId = onCustomTabListener.getTabLayoutResId(position);
        if (tabResId != 0) {
            tabView = inflater.inflate(tabResId, null);
        } else {
            tabView = onCustomTabListener.getTabLayoutView(inflater, position);
        }
        screenAdaptation = onCustomTabListener.screenAdaptation();
    }
    if (tabView == null) {
        tabView = inflater.inflate(R.layout.tab_layout_main, null);
    }
    TextView titleTV = ((TextView) tabView.findViewById(R.id.tab_title_label));
    final boolean needAdaptation = ScreenUtil.density <= 1.5 && screenAdaptation;
    final Resources resources = getContext().getResources();
    if (titleTV != null) {
        titleTV.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_11)
                        : resources.getDimensionPixelSize(R.dimen.text_size_15));
        titleTV.setText(title);
    }

    final DropFake unreadTV = ((DropFake) tabView.findViewById(R.id.tab_new_msg_label));
    if (unreadTV != null) {
        unreadTV.setTouchListener(new DropFake.ITouchListener() {
            @Override
            public void onDown() {
                DropManager.getInstance().setCurrentId(String.valueOf(position));
                DropManager.getInstance().down(unreadTV, unreadTV.getText());
            }

            @Override
            public void onMove(float curX, float curY) {
                DropManager.getInstance().move(curX, curY);
            }

            @Override
            public void onUp() {
                DropManager.getInstance().up();
            }
        });

        //unreadTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_9) : resources.getDimensionPixelSize(R.dimen.text_size_12));
    }
    addTab(position, tabView);
}

From source file:cn.liucl.stationarytabstrip.PagerSlidingTabStrip.java

private void updateTabStyles(boolean isSelected, View v) {
    v.setBackgroundResource(tabBackgroundResId);

    if (v instanceof TextView) {

        TextView tab = (TextView) v;/*ww w . ja v  a  2s  .c om*/
        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 (isSelected) {
            tab.setTextColor(selectedTabTextColor);
        }
    }
}

From source file:com.jihao.imtest.viewpager.PagerSlidingTabStrip.java

private void addTabView(final int position, String title) {
    View tabView = null;//from   w  w  w  .  j a va  2 s  .co m
    boolean screenAdaptation = false;
    final LayoutInflater inflater = LayoutInflater.from(getContext());
    if (this.onCustomTabListener != null) {
        int tabResId = onCustomTabListener.getTabLayoutResId(position);
        if (tabResId != 0) {
            tabView = inflater.inflate(tabResId, null);
        } else {
            tabView = onCustomTabListener.getTabLayoutView(inflater, position);
        }
        screenAdaptation = onCustomTabListener.screenAdaptation();
    }
    if (tabView == null) {
        tabView = inflater.inflate(R.layout.tab_layout_main, null);
    }
    TextView titltTV = ((TextView) tabView.findViewById(R.id.tab_title_label));
    TextView unreadTV = ((TextView) tabView.findViewById(R.id.tab_new_msg_label));
    final boolean needAdaptation = ScreenUtil.density <= 1.5 && screenAdaptation;
    final Resources resources = getContext().getResources();
    if (titltTV != null) {
        //            titltTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_11) : resources.getDimensionPixelSize(R.dimen.text_size_15));
        titltTV.setText(title);
    }
    if (unreadTV != null) {
        unreadTV.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                needAdaptation ? resources.getDimensionPixelSize(R.dimen.text_size_9)
                        : resources.getDimensionPixelSize(R.dimen.text_size_12));
    }
    addTab(position, tabView);
}

From source file:com.easemob.easeui.widget.viewpagerindicator.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//w w  w. j a va 2  s  . c  om
    tab.setSingleLine();
    tab.setTextColor(tabTextColor);
    tab.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    addTab(position, tab);

}

From source file:com.zch.safelottery.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);
        /**4???**/
        v.setLayoutParams(defaultTabLayoutParams);
        //         v.setLayoutParams(expandedTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);/*from  ww w .j  av  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);

            // 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.dudu.duduhelper.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof View) {

            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 a  v a2s.  co  m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.ninexiu.sixninexiu.lib.indicator.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(tabTextColorSelected);
            } else {
                tab.setTextColor(tabTextColorUnselected);
            }//from   w w  w .jav a 2s  .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: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));
                }/*from  w ww  .ja  v a  2 s .c  o  m*/
            }
        }
    }

}

From source file:com.astuetz.PagerSlidingTabStripExtendsBak.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));
                }/*www.j av  a2 s  . c  om*/
            }
            /*  ------------------  2016-4-12*/
            if (mSelectedPosition == i) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
                tab.setTextColor(selectedTabTextColor);
            }
            /* ---------------------------  2016-4-12*/
        }
    }

}