use of android.graphics.drawable.ShapeDrawable in project AndroidPicker by gzu-liyujiang.
the class BaseDialog method setBackgroundColor.
public final void setBackgroundColor(@CornerRound int cornerRound, @Dimension(unit = Dimension.DP) int radius, @ColorInt int color) {
if (contentView == null) {
return;
}
float radiusInPX = contentView.getResources().getDisplayMetrics().density * radius;
contentView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Drawable drawable;
switch(cornerRound) {
case CornerRound.Top:
float[] outerRadii = new float[] { radiusInPX, radiusInPX, radiusInPX, radiusInPX, 0, 0, 0, 0 };
ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(outerRadii, null, null));
shapeDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
drawable = shapeDrawable;
break;
case CornerRound.All:
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setCornerRadius(radiusInPX);
gradientDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
drawable = gradientDrawable;
break;
default:
drawable = new ColorDrawable(color);
break;
}
contentView.setBackground(drawable);
}
use of android.graphics.drawable.ShapeDrawable in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class MaterialProgressDrawable method setUp.
private void setUp(final double diameter) {
PtrLocalDisplay.init(mParent.getContext());
final int shadowYOffset = PtrLocalDisplay.dp2px(Y_OFFSET);
final int shadowXOffset = PtrLocalDisplay.dp2px(X_OFFSET);
int mShadowRadius = PtrLocalDisplay.dp2px(SHADOW_RADIUS);
OvalShape oval = new OvalShadow(mShadowRadius, (int) diameter);
mShadow = new ShapeDrawable(oval);
if (Build.VERSION.SDK_INT >= 11) {
mParent.setLayerType(View.LAYER_TYPE_SOFTWARE, mShadow.getPaint());
}
mShadow.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
}
use of android.graphics.drawable.ShapeDrawable in project Android-MaterialRefreshLayout by android-cjj.
the class CircleProgressBar method setBackgroundColor.
/**
* Update the background color of the mBgCircle image view.
*/
public void setBackgroundColor(int colorRes) {
if (getBackground() instanceof ShapeDrawable) {
final Resources res = getResources();
((ShapeDrawable) getBackground()).getPaint().setColor(res.getColor(colorRes));
}
}
use of android.graphics.drawable.ShapeDrawable in project Libraries-for-Android-Developers by eoecn.
the class IcsProgressBar method tileify.
/**
* Converts a drawable to a tiled version of itself. It will recursively
* traverse layer and state list drawables.
*/
private Drawable tileify(Drawable drawable, boolean clip) {
if (drawable instanceof LayerDrawable) {
LayerDrawable background = (LayerDrawable) drawable;
final int N = background.getNumberOfLayers();
Drawable[] outDrawables = new Drawable[N];
for (int i = 0; i < N; i++) {
int id = background.getId(i);
outDrawables[i] = tileify(background.getDrawable(i), (id == android.R.id.progress || id == android.R.id.secondaryProgress));
}
LayerDrawable newBg = new LayerDrawable(outDrawables);
for (int i = 0; i < N; i++) {
newBg.setId(i, background.getId(i));
}
return newBg;
} else /* else if (drawable instanceof StateListDrawable) {
StateListDrawable in = (StateListDrawable) drawable;
StateListDrawable out = new StateListDrawable();
int numStates = in.getStateCount();
for (int i = 0; i < numStates; i++) {
out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
}
return out;
}*/
if (drawable instanceof BitmapDrawable) {
final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
if (mSampleTile == null) {
mSampleTile = tileBitmap;
}
final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
final BitmapShader bitmapShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
shapeDrawable.getPaint().setShader(bitmapShader);
return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable;
}
return drawable;
}
use of android.graphics.drawable.ShapeDrawable in project BottomBar by roughike.
the class BottomBarBadge method setColoredCircleBackground.
void setColoredCircleBackground(int circleColor) {
int innerPadding = MiscUtils.dpToPixel(getContext(), 1);
ShapeDrawable backgroundCircle = BadgeCircle.make(innerPadding * 3, circleColor);
setPadding(innerPadding, innerPadding, innerPadding, innerPadding);
setBackgroundCompat(backgroundCircle);
}
Aggregations