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.szhr.noname.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 ww w . j av  a 2  s  . c o  m
            }
        }
    }

}

From source file:com.itheima.googlemarket.PagerSlidingTabStrip.java

@SuppressWarnings("deprecation")
private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        // StateListDrawable?????.
        StateListDrawable selector = createSelector(tabBackgroundPressed, tabBackgroundNormal);
        v.setBackgroundDrawable(selector);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            tab.setPadding(tabPadding, 0, tabPadding, 0);

            // 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 va2 s.  c  o m
            }
        }
    }

}

From source file:com.jinzht.pro.smarttablayout.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* w  w  w.j a v  a  2s. c om*/
 */
protected TextView createDefaultTabView(CharSequence title) {
    TextView textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setText(title);
    textView.setTextColor(tabViewTextColors);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setSingleLine(true);
    UiHelp.textBold(textView);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (tabViewBackgroundResId != NO_ID) {
        textView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(tabViewTextAllCaps);
    }

    textView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        textView.setMinWidth(tabViewTextMinWidth);
    }

    return textView;
}

From source file:com.common.view.tab.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 == currentPosition) {
                tab.setTextColor(tabScrollTextColor);
            } else {
                tab.setTextColor(tabTextColor);
            }/*from ww w.  j a  va 2s  . 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:caesar.feng.framework.percentlayout.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;/*  w  w  w . j a va2  s .c om*/

    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.example.recycleviewtest.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 ww w.  j av  a  2 s  .c o m*/

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

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

From source file:com.astuetz.PagerSlidingTabStripCopy.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. j a  va 2  s  .  com*/

            }
            if (mCurrent == i) {
                tab.setTextSize(mTitleSelectedSize);
                tab.setTypeface(tabTypeface, tabTypefaceStyle);
                tab.setTextColor(mTitleSelectedColor);
            }
        }
    }

}

From source file:android.percent.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;/* w w w.j  a  v  a2  s.  c om*/

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

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

From source file:nit.contact.views.PagerSlidingTabStrip.java

private void updateTabStyles() {

    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, Typeface.BOLD);
            if (tabTextColorStateList != null) {
                tab.setTextColor(tabTextColorStateList);
            } else {
                tab.setTextColor(tabTextColor);
            }/*  w  w  w  .  ja  v  a2  s . 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));
                }
            }
        } else if (v instanceof ViewGroup) {
            int numChildView = ((ViewGroup) v).getChildCount();
            View childView;
            for (int j = 0; j < numChildView; j++) {
                childView = ((ViewGroup) v).getChildAt(j);
                if (childView instanceof TextView) {
                    TextView tab = (TextView) childView;
                    tab.setTypeface(tabTypeface, Typeface.BOLD);
                    if (tabTextColorStateList != null) {
                        tab.setTextColor(tabTextColorStateList);
                    } 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.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java

private void addTabView(final int position, String title) {
    View tabView = null;/*  w w w  . java2 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 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);
}