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.supermonkey.lifeassistant.view.pager.PagerSlidingTabStrip.java

/**
 * tab?/*from   ww w  . j av a 2s  .co m*/
 */
private void updateTabStyles() {

    // tab
    for (int i = 0; i < tabCount; i++) {
        // ??
        View v = tabsContainer.getChildAt(i);
        // 
        v.setBackgroundResource(tabBackgroundResId);
        // ?TextView
        if (v instanceof TextView) {
            // 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 source file:net.osmand.plus.views.controls.PagerSlidingTabStrip.java

private void updateTabStyles() {
    tabsContainer.setBackgroundResource(tabBackgroundResId);
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            tab_title.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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }//from www  .  ja va 2s  .co m
            }
        }
    }
}

From source file:cn.mailchat.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {
        RelativeLayout tabLayout = (RelativeLayout) tabsContainer.getChildAt(i);
        View v = tabLayout.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);
            ///*from   www  . j  av a 2 s. 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));
            // }
            // }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }

}

From source file:com.astuetz.PagerSlidingTabStripPlus.java

private void updateTabStyles() {

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

        for (int k = 0; k < ((LinearLayout) tabsContainer.getChildAt(i)).getChildCount(); k++) {

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

            v.setBackgroundResource(tabBackgroundResId);

            if (v instanceof TextView) {

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

                // Setting color of textView
                if (textColorTab != null) {
                    tab.setTextColor(textColorTab);
                } else {
                    tab.setTextColor(Color.BLACK);
                }/*from   w  w w.java2s  .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:com.waz.zclient.pages.main.participants.ParticipantHeaderFragment.java

@Override
public void otherUserUpdated(final User otherUser) {
    headerReadOnlyTextView.setText(otherUser.getName());

    // TODO: https://wearezeta.atlassian.net/browse/AN-4278
    //        textViewAddressBookNameContainer.setVisibility(View.VISIBLE);
    //        textViewAddressBookName.setText("Marc Prengemann");

    subHeader.setText(otherUser.getEmail());
    subHeader.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            getResources().getDimension(R.dimen.participants__subheader__font_size__one_to_one));
    subHeader.setOnClickListener(new View.OnClickListener() {
        @Override//ww w .  jav a2 s .  c  o m
        public void onClick(View v) {
            final Uri uri = Uri.parse(String.format("mailto:%s", otherUser.getEmail()));
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });

    shieldView.setVisibility(otherUser.getVerified() == Verification.VERIFIED ? View.VISIBLE : View.INVISIBLE);

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            if (getView() != null && getControllerFactory().getConversationScreenController() != null) {
                final int height = getView().getMeasuredHeight();
                getControllerFactory().getConversationScreenController().setParticipantHeaderHeight(height);
            }
        }
    });
}

From source file:au.com.zacher.popularmovies.activity.layout.CollapsingTitleLayout.java

/**
 * Recursive binary search to find the best size for the text
 *
 * Adapted from https://github.com/grantland/android-autofittextview
 *///  w  w w .  j  a v  a  2 s  . co  m
private static float getSingleLineTextSize(String text, TextPaint paint, float targetWidth, float low,
        float high, float precision, DisplayMetrics metrics) {
    final float mid = (low + high) / 2.0f;

    paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, mid, metrics));
    final float maxLineWidth = paint.measureText(text);

    if ((high - low) < precision) {
        return low;
    } else if (maxLineWidth > targetWidth) {
        return getSingleLineTextSize(text, paint, targetWidth, low, mid, precision, metrics);
    } else if (maxLineWidth < targetWidth) {
        return getSingleLineTextSize(text, paint, targetWidth, mid, high, precision, metrics);
    } else {
        return mid;
    }
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static void getSizeAndUnits(final String size, final float[] result) {
    int units = TypedValue.COMPLEX_UNIT_PX;
    float value = 15.0f;
    String unitString = null;/*  ww w  . j a v a 2  s  . co m*/

    if (size != null) {
        Matcher m = SIZED_VALUE.matcher(size.trim());
        if (m.matches()) {
            if (m.groupCount() == 2) {
                unitString = m.group(2);
                value = Float.parseFloat(m.group(1));
            }
        }
    }

    if (unitString == null) {
        unitString = TiApplication.getInstance().getDefaultUnit();
    }

    if (TiDimension.UNIT_PX.equals(unitString) || TiDimension.UNIT_SYSTEM.equals(unitString)) {
        units = TypedValue.COMPLEX_UNIT_PX;
    } else if (TiDimension.UNIT_PT.equals(unitString)) {
        units = TypedValue.COMPLEX_UNIT_PT;
    } else if (TiDimension.UNIT_DP.equals(unitString) || TiDimension.UNIT_DIP.equals(unitString)) {
        units = TypedValue.COMPLEX_UNIT_DIP;
    } else if (TiDimension.UNIT_SP.equals(unitString) || TiDimension.UNIT_SIP.equals(unitString)) {
        units = TypedValue.COMPLEX_UNIT_SP;
    } else if (TiDimension.UNIT_MM.equals(unitString)) {
        units = TypedValue.COMPLEX_UNIT_MM;
    } else if (TiDimension.UNIT_CM.equals(unitString)) {
        units = TypedValue.COMPLEX_UNIT_MM;
        value *= 10;
    } else if (TiDimension.UNIT_IN.equals(unitString)) {
        units = TypedValue.COMPLEX_UNIT_IN;
    } else {
        if (unitString != null) {
            Log.w(TAG, "Unknown unit: " + unitString, Log.DEBUG_MODE);
        }
    }
    result[0] = units;
    result[1] = value;
}

From source file:net.yaly.ViewPagerDoubleIndicator.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.vpdi_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }/*  www .j  a  va 2 s .co m*/
            }
        }
    }
}

From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java

/** update the style of title text */
private void updateTabTextStyle(TextView tab, int color) {
    tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
    tab.setTypeface(mTabTypeface, mTabTypefaceStyle);
    tab.setTextColor(color);//  w  ww .j  ava  2s.co  m
}

From source file:com.freud.mrzz.views.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.tv_tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }/*from  www.  j a va  2  s  .co  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_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}