use of android.graphics.drawable.LayerDrawable in project Depth-LIB-Android- by danielzeller.
the class WindFragment method setProgressBarColor.
public static void setProgressBarColor(SeekBar progressBar, int newColor) {
if (progressBar.getProgressDrawable() instanceof StateListDrawable) {
StateListDrawable ld = (StateListDrawable) progressBar.getProgressDrawable();
ld.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
progressBar.getThumb().setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
} else if (progressBar.getProgressDrawable() instanceof LayerDrawable) {
LayerDrawable ld = (LayerDrawable) progressBar.getProgressDrawable();
for (int i = 0; i < ld.getNumberOfLayers(); i++) {
Drawable d1 = ld.getDrawable(i);
d1.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
}
progressBar.getThumb().setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
}
}
use of android.graphics.drawable.LayerDrawable in project cw-omnibus by commonsguy.
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.LayerDrawable in project cw-omnibus by commonsguy.
the class IcsProgressBar method doRefreshProgress.
private synchronized void doRefreshProgress(int id, int progress, boolean fromUser, boolean callBackToApp) {
float scale = mMax > 0 ? (float) progress / (float) mMax : 0;
final Drawable d = mCurrentDrawable;
if (d != null) {
Drawable progressDrawable = null;
if (d instanceof LayerDrawable) {
progressDrawable = ((LayerDrawable) d).findDrawableByLayerId(id);
}
final int level = (int) (scale * MAX_LEVEL);
(progressDrawable != null ? progressDrawable : d).setLevel(level);
} else {
invalidate();
}
if (callBackToApp && id == android.R.id.progress) {
onProgressRefresh(scale, fromUser);
}
}
use of android.graphics.drawable.LayerDrawable in project UltimateAndroid by cymcsg.
the class PagerSlidingTabStripActivity method changeColor.
private void changeColor(int newColor) {
tabs.setBackgroundColor(newColor);
mTintManager.setTintColor(newColor);
// change ActionBar color just if an ActionBar is available
Drawable colorDrawable = new ColorDrawable(newColor);
Drawable bottomDrawable = new ColorDrawable(getResources().getColor(android.R.color.transparent));
LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });
if (oldBackground == null) {
getSupportActionBar().setBackgroundDrawable(ld);
} else {
TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });
getSupportActionBar().setBackgroundDrawable(td);
td.startTransition(200);
}
oldBackground = ld;
currentColor = newColor;
}
use of android.graphics.drawable.LayerDrawable in project android-maps-utils by googlemaps.
the class DefaultClusterRenderer method makeClusterBackground.
private LayerDrawable makeClusterBackground() {
mColoredCircleBackground = new ShapeDrawable(new OvalShape());
ShapeDrawable outline = new ShapeDrawable(new OvalShape());
// Transparent white.
outline.getPaint().setColor(0x80ffffff);
LayerDrawable background = new LayerDrawable(new Drawable[] { outline, mColoredCircleBackground });
int strokeWidth = (int) (mDensity * 3);
background.setLayerInset(1, strokeWidth, strokeWidth, strokeWidth, strokeWidth);
return background;
}
Aggregations