List of usage examples for android.graphics.drawable Drawable getMinimumHeight
public int getMinimumHeight()
From source file:Main.java
public static Bitmap DrawToBitmap(Drawable dw) { Bitmap bitmap = Bitmap.createBitmap(dw.getMinimumWidth(), dw.getMinimumHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); dw.setBounds(0, 0, dw.getMinimumWidth(), dw.getMinimumHeight()); dw.draw(canvas);//from w ww . j a v a 2s .c o m return bitmap; }
From source file:Main.java
public static Drawable getDrawable(@Nullable Context context, @Nullable int id) { Drawable draw = context.getResources().getDrawable(id); draw.setBounds(0, 0, draw.getMinimumWidth(), draw.getMinimumHeight()); return draw;//from w w w .j av a 2s . c om }
From source file:Main.java
public static Bitmap toBitmap(Drawable drawable) { int w = drawable.getMinimumWidth(); int h = drawable.getMinimumHeight(); if (w <= 0 || h <= 0) { return null; }//from w ww . j av a 2s. co m Rect bounds = drawable.getBounds(); Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, w, h); drawable.draw(canvas); drawable.setBounds(bounds); return bitmap; }
From source file:Main.java
public static Drawable toGreyDrawable(Drawable drawable) { int w = drawable.getMinimumWidth(); int h = drawable.getMinimumHeight(); if (w <= 0 || h <= 0) { return drawable; }/*from www . jav a2s. c om*/ Rect bounds = drawable.getBounds(); Bitmap grey = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(grey); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); drawable.setColorFilter(new ColorMatrixColorFilter(cm)); drawable.setBounds(0, 0, w, h); drawable.draw(c); drawable.clearColorFilter(); drawable.setBounds(bounds); BitmapDrawable bd = new BitmapDrawable(grey); bd.setBounds(0, 0, w, h); return bd; }
From source file:Main.java
public static Drawable getDrawable(Context context, int R_ID) { Drawable brawable = context.getResources().getDrawable(R_ID); brawable.setBounds(0, 0, brawable.getMinimumWidth(), brawable.getMinimumHeight()); return brawable; }
From source file:Main.java
public static Drawable getCompoundDrawable(@NonNull Context context, @DrawableRes int resId) { Drawable drawable = context.getResources().getDrawable(resId); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); return drawable; }
From source file:Main.java
public static void textViewSetImg(Context context, TextView tv, int resId) { Drawable drawable = context.getResources().getDrawable(resId); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tv.setCompoundDrawables(drawable, null, null, null); }
From source file:Main.java
@SuppressWarnings("deprecation") public static void setTvLeftPic(Context context, int resId, TextView tv) { Drawable drawable = context.getResources().getDrawable(resId); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tv.setCompoundDrawables(drawable, null, null, null); }
From source file:Main.java
public static Drawable toGrey(Drawable drawable) { int w = drawable.getMinimumWidth(); int h = drawable.getMinimumHeight(); if (w <= 0 || h <= 0) { return drawable; }/*from w w w. j a v a 2s . com*/ Rect bounds = drawable.getBounds(); Bitmap grey = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(grey); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); drawable.setColorFilter(new ColorMatrixColorFilter(cm)); drawable.setBounds(0, 0, w, h); drawable.draw(c); drawable.clearColorFilter(); drawable.setBounds(bounds); BitmapDrawable bd = new BitmapDrawable(grey); bd.setBounds(0, 0, w, h); return bd; }
From source file:Main.java
public static void setRightCheckBoxDrawable(Context context, int drawableId, CheckBox box) { Drawable drawable = context.getResources().getDrawable(drawableId); // / drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); box.setCompoundDrawables(null, null, drawable, null); }