List of usage examples for android.graphics.drawable.shapes OvalShape OvalShape
public OvalShape()
From source file:org.opensilk.common.ui.widget.ColorCodedThumbnail.java
public void init(String title) { Integer color = null;//from w w w . j a v a 2 s. com if (!TextUtils.isEmpty(title)) { if (title.equals("..")) { setText(title); color = R.color.red; } else { Character c = title.toUpperCase(Locale.US).charAt(0); setText(c.toString()); if (c.compareTo('A') >= 0 && c.compareTo('Z') <= 0) { color = COLORS.get(c); } else if (c.compareTo('0') >= 0 && c.compareTo('9') <= 0) { color = COLORS.get(COLORS.keyAt(Integer.valueOf(c.toString()))); } } } if (color == null) { color = R.color.gray; } ShapeDrawable bg = new ShapeDrawable(new OvalShape()); bg.getPaint().setColor(getResources().getColor(color)); setBackgroundDrawable(bg); }
From source file:com.wudoumi.battertest.view.CircleImageView.java
private void init(int color, final float radius) { final float density = getContext().getResources().getDisplayMetrics().density; final int diameter = (int) (radius * density * 2); final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); ShapeDrawable circle;//from w ww . j av a 2 s . c o m if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, diameter); circle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint()); circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } circle.getPaint().setColor(color); setBackgroundDrawable(circle); }
From source file:com.justplay1.shoppist.shared.widget.animboxes.SelectBoxView.java
private ShapeDrawable createShape(Integer color) { if (color == null) return null; OvalShape ovalShape = new OvalShape(); shapeDrawable.setShape(ovalShape);//w ww. j a v a 2 s.co m shapeDrawable.getPaint().setColor(color); return shapeDrawable; }
From source file:org.mariotaku.twidere.view.HomeActionButton.java
@Override public void setButtonColor(int color) { if (isInEditMode()) { final ShapeDrawable sd = new ShapeDrawable(new OvalShape()); sd.getPaint().setColor(color);//from w w w. j a va2 s .co m ViewSupport.setBackground(this, sd); } else { ViewSupport.setBackground(this, new ColorDrawable(color)); } }
From source file:ezy.ui.view.ViewPagerIndicator.java
Drawable genDrawable(int color) { ShapeDrawable drawable = new ShapeDrawable(new OvalShape()); drawable.getPaint().setColor(color); drawable.getPaint().setAntiAlias(true); return drawable; }
From source file:org.opensilk.common.ui.widget.FloatingActionButton.java
/** * >= api 21// w ww. java 2s .c o m */ @SuppressWarnings("NewApi") protected RippleDrawable createRippleDrawable() { ShapeDrawable drawable = new ShapeDrawable(new OvalShape()); drawable.getPaint().setColor(mColorNormal); return new RippleDrawable(createRippleStateList(), drawable, null); }
From source file:br.ufrgs.ufrgsmapas.views.BuildingClusterRenderer.java
private LayerDrawable makeClusterBackground() { this.mColoredCircleBackground = new ShapeDrawable(new OvalShape()); ShapeDrawable outline = new ShapeDrawable(new OvalShape()); outline.getPaint().setColor(-2130706433); LayerDrawable background = new LayerDrawable(new Drawable[] { outline, this.mColoredCircleBackground }); int strokeWidth = (int) (this.mDensity * 3.0F); background.setLayerInset(1, strokeWidth, strokeWidth, strokeWidth, strokeWidth); return background; }
From source file:com.nick.documents.widget.FlexibleImageView.java
@SuppressLint("DrawAllocation") @Override/*from ww w .ja v a2 s .com*/ protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); final float density = getContext().getResources().getDisplayMetrics().density; mDiameter = Math.min(getMeasuredWidth(), getMeasuredHeight()); if (mDiameter <= 0) { mDiameter = (int) density * DEFAULT_CIRCLE_DIAMETER; } if (getBackground() == null && mCircleBackgroundEnabled) { mBgCircle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); mBgCircle.getPaint().setColor(mBgColor); setBackground(mBgCircle); } mProgressDrawable.setBackgroundColor(mBgColor); mProgressDrawable.setColorSchemeColors(mRingColors); mProgressDrawable.setSizeParameters(mDiameter, mDiameter, mInnerRadius <= 0 ? (mDiameter - mProgressStokeWidth * 2) / 4 : mInnerRadius, mProgressStokeWidth, mProgressStokeWidth * 4, mProgressStokeWidth * 2); super.setImageDrawable(null); super.setImageDrawable(mProgressDrawable); mProgressDrawable.setAlpha(255); mHandler.postDelayed(new Runnable() { @Override public void run() { mProgressDrawable.start(); } }, ANIMATE_START_DELAY); }
From source file:am.widget.MaterialProgressImageView.java
/** * /* w w w. java 2 s . c om*/ * * @param color */ public void setShadowsCircleBackground(int color) { if (background == null) { if (elevationSupported()) { background = new ShapeDrawable(new OvalShape()); } else { background = new ShapeDrawable(new OvalShadow()); } } background.getPaint().setColor(color); showShadowsCircle = true; super.setBackgroundDrawable(background); }
From source file:org.opensilk.common.ui.widget.FloatingActionButton.java
/** * <= api 19//ww w. ja va2 s . c o m */ protected Drawable createSelectableDrawable() { ShapeDrawable drawableNormal = new ShapeDrawable(new OvalShape()); drawableNormal.getPaint().setColor(mColorNormal); StateListDrawable stateDrawable = new StateListDrawable(); ShapeDrawable drawableHighlight = new ShapeDrawable(new OvalShape()); drawableHighlight.getPaint().setColor(mColorPressed); stateDrawable.addState(new int[] { android.R.attr.state_pressed }, drawableHighlight); stateDrawable.addState(new int[0], null); LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { drawableNormal, stateDrawable }); return layerDrawable; }