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.hadis.hadispagerslidingtabstrip.tabutil.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  ww.ja  va  2s.  c o  m
            }

            // by Hadis
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
            }
        }
    }

}

From source file:com.oo58.jelly.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) {
                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 .  ja va 2s .c om
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }
}

From source file:com.astuetz.PagerSlidingTabStripMy.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, pstsTabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(pstsTabTextColor);

            // 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. j  a v  a2s.  com
            }

            if (mCurrentPosition == i) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, pstsSelectedTextSize);
                tab.setTypeface(tabTypeface, tabTypefaceStyle);
                tab.setTextColor(pstsSelecedTextcolor);
            }
        }
    }

}

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);
        }/* ww  w  . ja v  a  2s.  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));
                }
            }
        }
    }
    setCurrentTabTextColor(selectedPosition);
}

From source file:com.worksum.android.nim.common.ui.viewpager.PagerSlidingTabStrip.java

private void addTabView(final int position, String title) {
    View tabView = null;/* w  w w .j av  a 2  s. c  o 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.setClickListener(new DropFake.ITouchListener() {
            @Override
            public void onDown() {
                DropManager.getInstance().setCurrentId(String.valueOf(position));
                DropManager.getInstance().getDropCover().down(unreadTV, unreadTV.getText());
            }

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

            @Override
            public void onUp() {
                DropManager.getInstance().getDropCover().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:com.neuwill.support.PercentLayoutHelper.java

private void supportTextSize(int widthHint, int heightHint, View view, PercentLayoutInfo info) {
    // textsize percent support

    PercentLayoutInfo.PercentVal textSizePercent = info.textSizePercent;
    if (textSizePercent == null)
        return;//from  w w w .  j av a2 s  .  c  o m

    int base = getBaseByModeAndVal(widthHint, heightHint, textSizePercent.basemode);
    float textSize = (int) (base * textSizePercent.percent);

    // Button  EditText TextView
    if (view instanceof TextView) {
        ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    }
}

From source file:com.astuetz.PagerSlidingTabStripExpand.java

/**
 *  ?/*from  w  w  w  .ja  v  a2  s .  com*/
 */
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 (mCurrentSelectedIndex == i) {
                tab.setTextColor(tabSelectedTextColor);
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
            }
        }
    }

}

From source file:com.astuetz.PagerSlidingTabStripCustom.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, textSize);//TODO
            //            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            //                tab.setTextColor(tabTextColor);
            tab.setTextColor(textColor);//TODO

            // 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  va2 s  .  c  o m
            }
            //TODO  ?pageTitle?
            if (mCurrentPosition == i) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectTextSize);
                tab.setTextColor(selectTextColor);
            }
        }
    }

}

From source file:com.luwei.ui.util.PagerSlidingTabStrip.java

private void textColorChange(int position) {

    View v = tabsContainer.getChildAt(position);

    v.setBackgroundResource(tabBackgroundResId);

    if (v instanceof TextView) {

        TextView tab = (TextView) v;//from   w ww .  j av a 2 s.  c o  m
        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 source file:com.yahala.ui.Views.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));
                }//from   w  ww  .j a  va 2s.  c  o m
            }
        } else if (v instanceof IconButton) {
            IconButton tab = (IconButton) v;
            tab.textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.textView.setTextColor(tabSwitch && i != 0 ? tabDeactivateTextColor : tabTextColor);
            v.setSelected(tabSwitch && i == 0 ? true : false);
        }
    }
}