use of android.graphics.drawable.ShapeDrawable in project android_packages_apps_OmniClock by omnirom.
the class ColorPickerPreference method createRectShape.
private static ShapeDrawable createRectShape(int width, int height, int color) {
ShapeDrawable shape = new ShapeDrawable(new RectShape());
shape.setIntrinsicHeight(height);
shape.setIntrinsicWidth(width);
shape.getPaint().setColor(color);
return shape;
}
use of android.graphics.drawable.ShapeDrawable in project Genius-Android by qiujuer.
the class TextView method setBorder.
/**
* Set the border, You can init border size, color and decision that direction contains border
*
* @param flag use {@link #BORDER_ALL } if you need All border,
* or {@link #BORDER_LEFT} the view will have Left border
* of case you can use eg: {@link #BORDER_LEFT}|{@link #BORDER_BOTTOM}
* the view will left and bottom border
* <p>
* if you not use border you need set the flag to 0
* @param size set all border size, unit is px, if you use dp, plx see {@link Ui#dipToPx(Resources, float)} )}
* @param color set all border color
*/
public void setBorder(int flag, int size, int color) {
if (mBorder != flag || mBorderSize != size || mBorderColor != color) {
mBorder = flag;
mBorderSize = size;
mBorderColor = color;
if (flag <= 0) {
mBorderDrawable = null;
} else {
RectF borderRect;
if ((flag & BORDER_ALL) == BORDER_ALL)
borderRect = new RectF(size, size, size, size);
else {
int l = 0, t = 0, r = 0, b = 0;
if ((flag & BORDER_LEFT) == BORDER_LEFT)
l = size;
if ((flag & BORDER_RIGHT) == BORDER_RIGHT)
r = size;
if ((flag & BORDER_TOP) == BORDER_TOP)
t = size;
if ((flag & BORDER_BOTTOM) == BORDER_BOTTOM)
b = size;
borderRect = new RectF(l, t, r, b);
}
if (mBorderDrawable == null) {
ShapeDrawable drawable = new ShapeDrawable(new BorderShape(borderRect));
Paint paint = drawable.getPaint();
paint.setColor(color);
drawable.setCallback(this);
mBorderDrawable = drawable;
} else {
ShapeDrawable drawable = (ShapeDrawable) mBorderDrawable;
Paint paint = drawable.getPaint();
paint.setColor(color);
BorderShape shape = (BorderShape) drawable.getShape();
shape.setBorder(borderRect);
}
}
invalidate();
}
}
use of android.graphics.drawable.ShapeDrawable in project MDM-Android-Agent by wso2-attic.
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 android_packages_apps_DU-Tweaks by DirtyUnicorns.
the class NotificationLightPreference method createOvalShape.
private static ShapeDrawable createOvalShape(int size, int color) {
ShapeDrawable shape = new ShapeDrawable(new OvalShape());
shape.setIntrinsicHeight(size);
shape.setIntrinsicWidth(size);
shape.getPaint().setColor(color);
return shape;
}
use of android.graphics.drawable.ShapeDrawable in project android_packages_apps_DU-Tweaks by DirtyUnicorns.
the class ColorPickerPreference method createOvalShape.
private static ShapeDrawable createOvalShape(int size, int color) {
ShapeDrawable shape = new ShapeDrawable(new OvalShape());
shape.setIntrinsicHeight(size);
shape.setIntrinsicWidth(size);
shape.getPaint().setColor(color);
return shape;
}
Aggregations