List of usage examples for android.util TypedValue COMPLEX_UNIT_PX
int COMPLEX_UNIT_PX
To view the source code for android.util TypedValue COMPLEX_UNIT_PX.
Click Source Link
From source file:com.socialinfotech.tabbar.smart.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 . jav a 2 s. c o m */ protected TextView createDefaultTabView(CharSequence title) { TextView textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); textView.setText(title); textView.setTextColor(mTabViewTextColors); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabViewTextSize); textView.setTypeface(Typeface.DEFAULT_BOLD); 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.little.pager.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundColor(Color.TRANSPARENT); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (colorArray == null || i > colorArray.length()) { tab.setTextColor(tabTextColor); } else { tab.setTextColor(colorArray.getColor(i, tabTextColor)); }//from w ww . jav a2 s .co 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)); } } if (i == selectedPosition) { // if (colorArray == null || i >= colorArray.length()) { //? if (hasFollowColor) { indicatorColor = selectedTabTextColor; } tab.setTextColor(selectedTabTextColor); } else { if (hasFollowColor) { indicatorColor = colorArray.getColor(i, selectedTabTextColor); } tab.setTextColor(colorArray.getColor(i, selectedTabTextColor)); } invalidate(); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize); } } } }
From source file:com.serveroverload.networkmaster.ui.PagerSlidingTabStrip.java
/** * Update tab styles.//from w ww . jav a 2 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)); } } } } }
From source file:com.shome.app.PagerSlidingTabStrip.java
private void updateTabStyles() { if (useToggleTab) { return;/*from www . j a v a2s . c o m*/ } for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); v.setPadding(0, 12, 0, 0); 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 source file:be.blinkt.openvpn.views.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); 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); if (tabTextColor != null) { tab_title.setTextColor(tabTextColor); }/* w w w . j a v a 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)); } } } } }
From source file:com.zaparound.PagerSlidingTabStrip.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.psts_tab_title); if (tab_title != null) { tab_title.setTextColor(mTabTextColor); tab_title.setTypeface(mTabTextTypeface); 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)); }// ww w .j a va 2 s.c o m } } } }
From source file:com.facebook.FacebookButtonBase.java
private void parseTextAttributes(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { final int colorResources[] = { android.R.attr.textColor, }; final TypedArray colorAttrs = context.getTheme().obtainStyledAttributes(attrs, colorResources, defStyleAttr, defStyleRes);//from ww w . ja va 2 s.c o m try { setTextColor(colorAttrs.getColor(0, Color.WHITE)); } finally { colorAttrs.recycle(); } final int gravityResources[] = { android.R.attr.gravity, }; final TypedArray gravityAttrs = context.getTheme().obtainStyledAttributes(attrs, gravityResources, defStyleAttr, defStyleRes); try { setGravity(gravityAttrs.getInt(0, Gravity.CENTER)); } finally { gravityAttrs.recycle(); } final int attrsResources[] = { android.R.attr.textSize, android.R.attr.textStyle, android.R.attr.text, }; final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, attrsResources, defStyleAttr, defStyleRes); try { setTextSize(TypedValue.COMPLEX_UNIT_PX, a.getDimensionPixelSize(0, 0)); setTypeface(Typeface.defaultFromStyle(a.getInt(1, Typeface.BOLD))); setText(a.getString(2)); } finally { a.recycle(); } }
From source file:com.example.linkagescroll.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 (i == currentPosition) { tab.setTextColor(tabTextSelectColor); } else { tab.setTextColor(tabTextColor); }//from w w w .ja v a 2 s . 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.csform.android.uiapptemplate.view.PagerSlidingTabStrip.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.psts_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)); }/*w w w . j av a 2 s . c o m*/ } } } }
From source file:com.gsbabil.antitaintdroid.UtilityFunctions.java
public int captureBitmapCache(String in) { TextView tv = (TextView) MyApp.context.findViewById(R.id.ocrTextview); String tvText = tv.getText().toString(); float tvTextSize = tv.getTextSize(); int tvColor = tv.getCurrentTextColor(); Bitmap bitmap = null;/*from ww w .ja v a2s . c o m*/ tv.setTextSize(36); tv.setTextColor(Color.CYAN); tv.setTypeface(Typeface.SANS_SERIF); tv.setText(in); while (bitmap == null) { // http://stackoverflow.com/questions/2339429/android-view-getdrawingcache-returns-null-only-null tv.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight()); tv.setDrawingCacheEnabled(true); tv.buildDrawingCache(true); bitmap = Bitmap.createBitmap(tv.getDrawingCache()); tv.destroyDrawingCache(); tv.setDrawingCacheEnabled(false); } FileOutputStream fos = null; int res = -1; try { fos = new FileOutputStream(currentDirectory() + "/files/" + MyApp.SCREENSHOT_FILENAME); if (fos != null) { bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos); fos.close(); res = 0; } } catch (Throwable e) { Log.i(MyApp.TAG, e.getMessage().toString()); res = -1; } tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvTextSize); tv.setTypeface(Typeface.MONOSPACE); tv.setText(tvText); tv.setTextColor(tvColor); return res; }