List of usage examples for android.graphics.drawable PaintDrawable PaintDrawable
public PaintDrawable(int color)
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 w w w.j ava 2 s . c om*/ 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:nf.frex.android.FrexActivity.java
/** * Called when the activity is first created. *//*from ww w.j ava 2 s . co m*/ @Override public void onCreate(Bundle savedInstanceState) { //Log.d(TAG, "onCreate(savedInstanceState=" + savedInstanceState + ")"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY); if (PRE_SDK14) { requestWindowFeature(Window.FEATURE_NO_TITLE); // Fix: Frex to stop working on screen orientation changes (Android 2.3.x only) if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else { getActionBar().setBackgroundDrawable(new PaintDrawable(Color.argb(128, 0, 0, 0))); } view = new FractalView(this); setContentView(view); if (!tryReadingFrexDocIntent(getIntent())) { if (savedInstanceState != null) { view.restoreInstanceState(new BundlePropertySet(savedInstanceState)); } else { PropertySet propertySet = (PropertySet) getLastNonConfigurationInstance(); if (propertySet != null) { view.restoreInstanceState(propertySet); } } } }
From source file:me.tylerbwong.pokebase.gui.views.PokemonInfoView.java
private void loadTypes(String[] types) { PaintDrawable backgroundColor;//from w w w . jav a2 s . c om float dimension = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); if (types.length == 1) { String type = types[0]; 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 a v a 2s.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. *///from w w w . j a va2 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); } }