List of usage examples for android.content.res Resources getDrawable
@Deprecated public Drawable getDrawable(@DrawableRes int id) throws NotFoundException
From source file:Main.java
/** * Get the {@link Drawable} identified by {@code drawableId} and set its bounds * with the dimensions identified by {@code widthDimenId} and {@code heightDimenId}. * @param ctx Context/* ww w. j av a 2s . c om*/ * @param drawableId Identifier of the drawable. * @param widthDimenId Identifier of the resource to use as the width. * @param heightDimenId Identifier of the resource to use as the height. * @return The {@link Drawable} identified by {@code drawableId} bounded to {@code widthDimenId} and {@code heightDimenId}. */ public static Drawable boundedDrawable(Context ctx, int drawableId, int widthDimenId, int heightDimenId) { Drawable retVal; Resources res = ctx.getResources(); retVal = res.getDrawable(drawableId); retVal.setBounds(0, 0, res.getDimensionPixelSize(widthDimenId), res.getDimensionPixelSize(heightDimenId)); return retVal; }
From source file:Main.java
private static Drawable getDrawable(Resources resources, int id) { try {//from w w w . ja v a 2s. c o m return resources.getDrawable(id); } catch (Resources.NotFoundException e) { // do nothing. } return null; }
From source file:Main.java
public static final Bitmap getBitmapImmutableCopy(Resources res, int id) { return getBitmap(res.getDrawable(id)).copy(Bitmap.Config.RGB_565, false); }
From source file:Main.java
public static BitmapDrawable asBitmapDrawable(Resources res, @DrawableRes int resId) { return asBitmapDrawable(res, res.getDrawable(resId)); }
From source file:Main.java
private static Bitmap drawToBitmap(Resources resources, int drawableResourceID, Bitmap bitmap) { Drawable drawable = resources.getDrawable(drawableResourceID); drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); drawable.draw(new Canvas(bitmap)); return bitmap; }
From source file:Main.java
public static BitmapDrawable createBitmapDrawableFrom(Resources res, @DrawableRes int resId) { return createBitmapDrawableFrom(res, res.getDrawable(resId)); }
From source file:Main.java
public static Drawable getDrawable(Context context, int res) { Resources resource = getResources(context);// .getResources(); Drawable d = resource.getDrawable(res); return setClearFilter(d); }
From source file:Main.java
public static Drawable getDrawable(Resources res, Resources.Theme theme, @DrawableRes int id) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return res.getDrawable(id); }// w w w . jav a 2 s . co m return res.getDrawable(id, theme); }
From source file:com.keepassdroid.icons.DrawableFactory.java
private static void initBlank(Resources res) { if (blank == null) { blank = res.getDrawable(R.drawable.ic99_blank); blankWidth = blank.getIntrinsicWidth(); blankHeight = blank.getIntrinsicHeight(); }//from w ww .ja va 2 s . com }
From source file:com.telly.mrvector.MrVector.java
/** * Inflates a <vector> drawable, using framework implementation when available * @param resources//w ww. j a v a 2 s . com * Resources to use for inflation * @param resId * <vector> drawable resource * @return * <p>Framework {@link android.graphics.drawable.VectorDrawable} if running lollipop or later.</p> * <p>{@link com.telly.mrvector.VectorDrawable} otherwise.</p> * * @see #inflateCompatOnly(android.content.res.Resources, int) */ public static Drawable inflate(Resources resources, @DrawableRes int resId) { if (LOLLIPOP_PLUS) { return resources.getDrawable(resId); } else { return inflateCompatOnly(resources, resId); } }