use of android.graphics.drawable.ShapeDrawable in project weex-example by KalicyZhou.
the class CircleProgressBar method setBackgroundColorResource.
/**
* Update the background color of the mBgCircle image view.
*/
public void setBackgroundColorResource(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 wire-android by wireapp.
the class ConversationQuickMenu method setAccentColor.
public void setAccentColor(int color) {
conversationButton.setAccentColor(color);
ShapeDrawable ovalBackground = new ShapeDrawable(new OvalShape());
ovalBackground.getPaint().setColor(color);
ovalBackground.getPaint().setStyle(Paint.Style.FILL);
ovalBackground.getPaint().setAntiAlias(true);
cameraButton.setBackground(ovalBackground);
callButton.setBackground(ovalBackground);
videoCallButton.setBackground(ovalBackground);
}
use of android.graphics.drawable.ShapeDrawable in project wire-android by wireapp.
the class AccentColorEditText method updateCursor.
protected void updateCursor() {
ShapeDrawable cursorDrawable = new ShapeDrawable(new RectShape());
cursorDrawable.setIntrinsicWidth(ViewUtils.toPx(getContext(), DEFAULT_CURSOR_WIDTH_DP));
cursorDrawable.getPaint().setColor(accentColor);
setHintCursorSize(cursorDrawable);
try {
// now attach the resource so it stops using the old one
Field ef = ReflectionUtils.getInheritedPrivateField(this.getClass(), "mEditor");
if (ef == null) {
return;
}
ef.setAccessible(true);
Object editorObject = ef.get(this);
Field df = ReflectionUtils.getInheritedPrivateField(editorObject.getClass(), "mCursorDrawable");
if (df == null) {
return;
}
df.setAccessible(true);
Object dfo = df.get(editorObject);
if (dfo == null || !(dfo instanceof Drawable[])) {
return;
}
Drawable[] darray = (Drawable[]) dfo;
for (int i = 0; i < darray.length; i++) {
darray[i] = cursorDrawable;
}
} catch (IllegalAccessException | IllegalArgumentException ex) {
Timber.e(ex, "Error accessing private field");
}
}
use of android.graphics.drawable.ShapeDrawable in project XobotOS by xamarin.
the class ProgressBar 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 == R.id.progress || id == R.id.secondaryProgress));
}
LayerDrawable newBg = new LayerDrawable(outDrawables);
for (int i = 0; i < N; i++) {
newBg.setId(i, background.getId(i));
}
return newBg;
} 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;
} else 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 PhotoNoter by yydcdut.
the class ColorChooserDialog method createSelector.
private Drawable createSelector(int color) {
ShapeDrawable coloredCircle = new ShapeDrawable(new OvalShape());
coloredCircle.getPaint().setColor(color);
ShapeDrawable darkerCircle = new ShapeDrawable(new OvalShape());
darkerCircle.getPaint().setColor(shiftColor(color));
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[] { -android.R.attr.state_pressed }, coloredCircle);
stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, darkerCircle);
return stateListDrawable;
}
Aggregations