public static Drawable FromDrawable(Drawable drawable, Resources r) { if (drawable != null) { if (drawable.GetType() == typeof(RoundedCornerDrawable)) { return(drawable); } else if (drawable.GetType() == typeof(LayerDrawable)) { LayerDrawable ld = drawable as LayerDrawable; int num = ld.NumberOfLayers; for (int i = 0; i < num; i++) { Drawable d = ld.GetDrawable(i); ld.SetDrawableByLayerId(ld.GetId(i), FromDrawable(d, r)); } return(ld); } Bitmap bm = DrawableToBitmap(drawable); if (bm != null) { return(new RoundedCornerDrawable(bm, r)); } } return(drawable); }
private void SetColor(ProgressBar bar, Color color) { LayerDrawable progressDrawable = (LayerDrawable)bar.ProgressDrawable; Drawable primaryColor = progressDrawable.GetDrawable(2); primaryColor.SetColorFilter(new LightingColorFilter(0, color)); progressDrawable.SetDrawableByLayerId(progressDrawable.GetId(2), new ClipDrawable(primaryColor, GravityFlags.Left, ClipDrawableOrientation.Horizontal)); }