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.astuetz.PagerSlidingTabStripExtend.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  a v a  2s.co m
            }

            //??
            if (i == mSelectedIndex) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabSelectedTextSize);
                tab.setTextColor(tabSelectedTextColor);
            }
        }
    }

}

From source file:com.astuetz.PagerSlidingTabStripExtends.java

/**
 * ?//  w  w  w .j  a v a2 s  .  c  o m
 */
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));
                }
            }

            /*--------------- add begin ---------------*/
            if (i == curSelectedPosition) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
                tab.setTypeface(tabTypeface, tabTypefaceStyle);
                tab.setTextColor(selectedTabTextColor);
            }
            /*--------------- add end ---------------*/
        }
    }

}

From source file:com.zxly.o2o.view.MPagerSlidingTab.java

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

    TextView tab = new TextView(getContext());
    tab.setPadding(DesityUtil.dp2px(getContext(), 6), 0, DesityUtil.dp2px(getContext(), 6), 0);
    tab.setText(title);/*from   w  ww.  jav a2s  .c  o  m*/
    tab.setSingleLine();
    tab.setTextColor(tabTextColor);
    tab.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL);
    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    addTab(position, tab);

}

From source file:com.hcpt.fastfood.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);
            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 .  j  av  a2  s .co m
            }
        }
    }

}

From source file:cc.wudoumi.framework.views.PagerSlidingTabStrip.java

private void updateTabTextSize(TextView tab) {
    if (tabTextSizeChange) {
        if (tab.isSelected()) {
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selecttabTextSize);
        } else {/*from   w w w  . j ava2s .  c om*/
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
        }
    }
}

From source file:com.ch.ch_library.smartlayout.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)}./*from   ww  w.  jav  a  2s  .co m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(mTabViewTextColor);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabViewTextSize);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    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(mTabViewTextAllCaps);
    }

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

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

    return textView;
}

From source file:com.carinsurance.pagerslidingtabstrip.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);
            // tab.setTextColor(Color.parseColor("#00a2d0"));

            // 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  .j  ava 2s  .  com
            }
        }
    }

}

From source file:com.cmax.bodysheild.widget.PagerSlidingTabStripExtends.java

/**
 * ?/*  w ww  .  j a  va  2 s  . c om*/
 */
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 (mSelectedPostion == i) {
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.research.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = ((LinearLayout) tabsContainer.getChildAt(i)).getChildAt(0);

        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  .  j  a v a  2s .  c om
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java

private void createItems() {
    String[] titles = getOtherButtonTitles();
    if (titles != null) {
        for (int i = 0; i < titles.length; i++) {
            Button bt = new Button(getActivity());
            bt.setId(CANCEL_BUTTON_ID + i + 1);
            bt.setOnClickListener(this);
            bt.setBackgroundDrawable(getOtherButtonBg(titles, i));
            bt.setText(titles[i]);/*from w  w  w . j a  v  a2s  .  c o m*/
            bt.setTextColor(mAttrs.otherButtonTextColor);
            bt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAttrs.actionSheetTextSize);
            if (i > 0) {
                LinearLayout.LayoutParams params = createButtonLayoutParams();
                params.topMargin = mAttrs.otherButtonSpacing;
                mPanel.addView(bt, params);
            } else {
                mPanel.addView(bt);
            }
        }
    }
    Button bt = new Button(getActivity());
    bt.getPaint().setFakeBoldText(true);
    bt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAttrs.actionSheetTextSize);
    bt.setId(ActionSheet.CANCEL_BUTTON_ID);
    bt.setBackgroundDrawable(mAttrs.cancelButtonBackground);
    bt.setText(getCancelButtonTitle());
    bt.setTextColor(mAttrs.cancelButtonTextColor);
    bt.setOnClickListener(this);
    LinearLayout.LayoutParams params = createButtonLayoutParams();
    params.topMargin = mAttrs.cancelButtonMarginTop;
    mPanel.addView(bt, params);

    mPanel.setBackgroundDrawable(mAttrs.background);
    mPanel.setPadding(mAttrs.padding, mAttrs.padding, mAttrs.padding, mAttrs.padding);
}