List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable
public ColorDrawable(@ColorInt int color)
From source file:Main.java
@SuppressWarnings("ResourceType") public static TransitionDrawable drawable2TransitionDrawable(Drawable drawable) { TransitionDrawable mBitmapDrawable = null; try {/*from w w w .jav a2s. c om*/ if (drawable == null) { return null; } mBitmapDrawable = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); } catch (Exception e) { e.printStackTrace(); } return mBitmapDrawable; }
From source file:Main.java
@SuppressWarnings("ResourceType") public static TransitionDrawable bitmap2TransitionDrawable(Bitmap bitmap) { TransitionDrawable mBitmapDrawable = null; try {//from w w w .j a va2s . c o m if (bitmap == null) { return null; } mBitmapDrawable = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(null, bitmap) }); } catch (Exception e) { e.printStackTrace(); } return mBitmapDrawable; }
From source file:Main.java
public static Drawable getAsssetDrawableByName(Context context, String name) { try {/* www .j a v a 2s. co m*/ InputStream is = context.getAssets().open(name); return new BitmapDrawable(context.getResources(), BitmapFactory.decodeStream(is)); } catch (IOException e) { e.printStackTrace(); } return new ColorDrawable(Color.TRANSPARENT); }
From source file:Main.java
public static Drawable getSelectedStateDrawableByResColor(Context context, int normalcolor_id, int selectedcolor_id) { // StateListDrawable drawable = new StateListDrawable(); // drawable.addState(new int[]{- android.R.attr.state_selected}, new // ColorDrawable( context.getResources().getColor(normalcolor_id))); // drawable.addState(new int[]{ android.R.attr.state_selected}, new // ColorDrawable( context.getResources().getColor(selectedcolor_id))); Drawable normal = new ColorDrawable(context.getResources().getColor(normalcolor_id)); Drawable selected = new ColorDrawable(context.getResources().getColor(selectedcolor_id)); return getSelectedStateDrawable(normal, selected); }
From source file:Main.java
private static Drawable getColorDrawable(int colorCode) { return new ColorDrawable(colorCode); }
From source file:Main.java
public static ColorDrawable getColorDrawableFromColor(int color) { return new ColorDrawable(color); }
From source file:Main.java
private static StateListDrawable getStateListDrawable(int pressedColor, Integer normalColor) { StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(pressedColor)); states.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(pressedColor)); states.addState(new int[] { android.R.attr.state_activated }, new ColorDrawable(pressedColor)); if (null != normalColor) states.addState(new int[] {}, new ColorDrawable(normalColor)); return states; }
From source file:Main.java
/** * Private method./*from w w w.jav a 2 s . c om*/ * * Returns a {@link GradientDrawable} with * no rounded corners. * * @param color The desired color of the GradientDrawable * @return A {@link GradientDrawable} */ private static ColorDrawable getLollipopBackground(int color) { return new ColorDrawable(color); }
From source file:com.hackaton.GlideUtil.java
public static void loadImage(String url, ImageView imageView) { Context context = imageView.getContext(); ColorDrawable cd = new ColorDrawable(ContextCompat.getColor(context, R.color.colorAccent)); Glide.with(context).load(url).placeholder(cd).crossFade().centerCrop().into(imageView); }
From source file:com.barak.pix.GlideUtil.java
public static void loadImage(String url, ImageView imageView) { Context context = imageView.getContext(); ColorDrawable cd = new ColorDrawable(ContextCompat.getColor(context, R.color.blue_grey_500)); Glide.with(context).load(url).placeholder(cd).crossFade().centerCrop().into(imageView); }