Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.drawable.Drawable; import android.support.annotation.Nullable; public class Main { 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; } }