List of usage examples for android.util TypedValue COMPLEX_UNIT_SP
int COMPLEX_UNIT_SP
To view the source code for android.util TypedValue COMPLEX_UNIT_SP.
Click Source Link
From source file:com.android.purenexussettings.utils.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getInteger(R.integer.slidetab_view_text_size_sp)); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true);/* w ww . j a v a 2 s .c o m*/ // some fudging around for padding of the tabs int paddingtb = (int) (getResources().getInteger(R.integer.slidetab_view_top_padding_dips) * getResources().getDisplayMetrics().density); int paddinglr = (int) (getResources().getInteger(R.integer.slidetab_view_padding_dips) * getResources().getDisplayMetrics().density); textView.setPadding(paddinglr, paddingtb, paddinglr, paddingtb); return textView; }
From source file:com.chaos.dmactiontabsexample.view.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true);/* w w w . ja v a2 s . c o m*/ int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.evilduck.piano.views.instrument.PianoView.java
public PianoView(Context context, AttributeSet attrs) { super(context, attrs); init();//from w w w . j a v a 2s .c o m leftEdgeEffect = new EdgeEffectCompat(getContext()); rightEdgeEffect = new EdgeEffectCompat(getContext()); setVerticalScrollBarEnabled(false); setHorizontalScrollBarEnabled(true); TypedArray a = context.obtainStyledAttributes(R.styleable.View); initializeScrollbars(a); a.recycle(); TypedArray pianoAttrs = context.obtainStyledAttributes(attrs, R.styleable.PianoView); boolean asBitmaps; int circleColor; float circleRadius; float circleTextSize; try { asBitmaps = pianoAttrs.getBoolean(R.styleable.PianoView_overlay_bitmaps, true); circleColor = pianoAttrs.getColor(R.styleable.PianoView_overlay_color, Color.GREEN); circleRadius = pianoAttrs.getDimension(R.styleable.PianoView_overlay_circle_radius, TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources().getDisplayMetrics())); circleTextSize = pianoAttrs.getDimension(R.styleable.PianoView_overlay_circle_text_size, TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, context.getResources().getDisplayMetrics())); } finally { pianoAttrs.recycle(); } keyboard = new Keyboard(getContext(), asBitmaps, circleColor, circleRadius, circleTextSize); }
From source file:com.example.emamianrizif.Movie.views.SlidingTabLayout.java
protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); }/* ww w.j a va2 s .c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.example.QQReader.OpenSourceWidget.astuetz.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from www. j av a 2 s . co m setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.commonsware.android.preso.decktastic.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_actions, menu); rc = (ReverseChronometer) menu.findItem(R.id.countdown).getActionView(); rc.setWarningDuration(5 * 60);//w w w . j a v a2 s . c o m rc.setOnClickListener(this); rc.setOnLongClickListener(this); rc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24); rc.setTextColor(Color.WHITE); if (durationInSeconds > 0) { rc.setOverallDuration(durationInSeconds); } MenuItem item = menu.findItem(R.id.route_provider); MediaRouteActionProvider provider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(item); provider.setRouteSelector(selector); return (super.onCreateOptionsMenu(menu)); }
From source file:com.huyn.demogroup.relativetop.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from w w w . ja va 2 s . co m setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.arcusapp.soundbox.fragment.SongsListFragment.java
private void addRandomButton() { // create the button Button myButton = new Button(getActivity()); myButton.setId(19);/*from w w w .ja v a2s . co m*/ myButton.setText(this.getString(R.string.LabelPlaySongsRandom)); myButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20); myButton.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.drawable.icon_random_shuffled), null); myButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //start the playActivity Intent playActivityIntent = new Intent(); playActivityIntent.setAction(SoundBoxApplication.ACTION_MAIN_ACTIVITY); playActivityIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); getActivity().startActivity(playActivityIntent); //call the service to play new songs Intent serviceIntent = new Intent(MediaPlayerService.PLAY_NEW_SONGS, null, SoundBoxApplication.getContext(), MediaPlayerService.class); Bundle b = new Bundle(); Collections.shuffle(songsIDs); b.putStringArrayList(BundleExtra.SONGS_ID_LIST, new ArrayList<String>(songsIDs)); b.putString(BundleExtra.CURRENT_ID, BundleExtra.DefaultValues.DEFAULT_ID); serviceIntent.putExtras(b); getActivity().startService(serviceIntent); } }); // add the button to the header of the list myListView.addHeaderView(myButton); }
From source file:com.greencode.enticement_android.UI.SlidingTabLayout.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)}.// ww w . ja va 2 s. c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); // textView.setBackgroundColor(R.color.bg_horizontal_item); 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(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.github.johnpersano.supertoasts.demo.views.TabStrip.java
public TabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*ww w . j a va 2 s . c o m*/ setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); indicatorPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, indicatorPadding, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(0, tabTextSize); a.recycle(); a = context.obtainStyledAttributes(attrs, R.styleable.TabStrip); indicatorColor = a.getColor(R.styleable.TabStrip_TabStripIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.TabStrip_TabStripUnderlineColor, underlineColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.TabStrip_TabStripIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.TabStrip_TabStripUnderlineHeight, underlineHeight); tabPadding = a.getDimensionPixelSize(R.styleable.TabStrip_TabStripTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.TabStrip_TabStripTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.TabStrip_TabStripShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.TabStrip_TabStripScrollOffset, scrollOffset); tabSwitch = a.getBoolean(R.styleable.TabStrip_TabStripTabSwitch, tabSwitch); tabTextColor = a.getColor(R.styleable.TabStrip_TabStripActivateTextColor, tabTextColor); tabDeactivateTextColor = a.getColor(R.styleable.TabStrip_TabStripDeactivateTextColor, tabDeactivateTextColor); indicatorPadding = a.getDimensionPixelSize(R.styleable.TabStrip_TabStripIndicatorPadding, indicatorPadding); a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }