List of usage examples for android.graphics.drawable PaintDrawable setCornerRadius
public void setCornerRadius(float radius)
From source file:me.tylerbwong.pokebase.gui.views.MoveInfoView.java
public void setFields(String type, String power, String pp, String accuracy, String className, String description) {//from ww w. j a v a 2s.com PaintDrawable backgroundColor; float dimension = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); this.typeLabel.setText(type); this.powerLabel.setText(power); this.ppLabel.setText(pp); this.accuracyLabel.setText(accuracy); classLabel.setText(className); this.description.setText(description); String classColor = CLASS + className; int colorResId = getResources().getIdentifier(classColor, COLOR, context.getPackageName()); backgroundColor = new PaintDrawable(ContextCompat.getColor(context, colorResId)); backgroundColor.setCornerRadius(dimension); classLabel.setBackground(backgroundColor); String typeColor = TYPE + type; colorResId = getResources().getIdentifier(typeColor, COLOR, context.getPackageName()); backgroundColor = new PaintDrawable(ContextCompat.getColor(context, colorResId)); backgroundColor.setCornerRadius(dimension); this.typeLabel.setBackground(backgroundColor); }
From source file:me.tylerbwong.pokebase.gui.views.PokemonInfoView.java
private void loadTypes(String[] types) { PaintDrawable backgroundColor; float dimension = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); if (types.length == 1) { String type = types[0];//ww w. java 2 s . c o m String colorName = TYPE + type; int colorResId = getResources().getIdentifier(colorName, COLOR, context.getPackageName()); typeTwoView.setVisibility(View.GONE); typeOneView.setText(type); backgroundColor = new PaintDrawable(ContextCompat.getColor(context, colorResId)); backgroundColor.setCornerRadius(dimension); typeOneView.setBackground(backgroundColor); } else { String typeOne = types[0]; String typeTwo = types[1]; String colorName = TYPE + typeOne; int colorResId = getResources().getIdentifier(colorName, COLOR, context.getPackageName()); typeOneView.setText(typeOne); backgroundColor = new PaintDrawable(ContextCompat.getColor(context, colorResId)); backgroundColor.setCornerRadius(dimension); typeOneView.setBackground(backgroundColor); typeTwoView.setVisibility(View.VISIBLE); typeTwoView.setText(typeTwo); colorName = TYPE + typeTwo; colorResId = getResources().getIdentifier(colorName, COLOR, context.getPackageName()); backgroundColor = new PaintDrawable(ContextCompat.getColor(context, colorResId)); backgroundColor.setCornerRadius(dimension); typeTwoView.setBackground(backgroundColor); } }
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
/** * Create or recreate the limiter breadcrumbs. */// w w w .j av a2 s . c o m public void updateLimiterViews() { mLimiterViews.removeAllViews(); Limiter limiterData = mPagerAdapter.getCurrentLimiter(); if (limiterData != null) { String[] limiter = limiterData.names; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = 5; for (int i = 0; i != limiter.length; ++i) { PaintDrawable background = new PaintDrawable(Color.GRAY); background.setCornerRadius(5); TextView view = new TextView(this); view.setSingleLine(); view.setEllipsize(TextUtils.TruncateAt.MARQUEE); view.setText(limiter[i] + " | X"); view.setTextColor(Color.WHITE); view.setBackgroundDrawable(background); view.setLayoutParams(params); view.setPadding(5, 2, 5, 2); view.setTag(i); view.setOnClickListener(this); mLimiterViews.addView(view); } mLimiterScroller.setVisibility(View.VISIBLE); } else { mLimiterScroller.setVisibility(View.GONE); } }
From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java
/** * Create or recreate the limiter breadcrumbs. */// w ww . ja va 2 s . c o m public void updateLimiterViews() { mLimiterViews.removeAllViews(); Limiter limiterData = mPagerAdapter.getCurrentLimiter(); if (limiterData != null) { String[] limiter = limiterData.names; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = 5; for (int i = 0; i != limiter.length; ++i) { int color = (i + 1 == limiter.length ? 0xFFA0A0A0 : 0xFFC0C0C0); PaintDrawable background = new PaintDrawable(color); background.setCornerRadius(0); TextView view = new TextView(this); view.setSingleLine(); view.setEllipsize(TextUtils.TruncateAt.MARQUEE); view.setText(limiter[i]); view.setTextColor(Color.WHITE); view.setBackgroundDrawable(background); view.setLayoutParams(params); view.setPadding(14, 6, 14, 6); view.setTag(i); view.setOnClickListener(this); mLimiterViews.addView(view); } mLimiterScroller.setVisibility(View.VISIBLE); } else { mLimiterScroller.setVisibility(View.GONE); } }