Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; public class Main { public static Drawable getDrawableIcon(Context context, int drawableIcon, int size) { Drawable drawable; drawable = ContextCompat.getDrawable(context, drawableIcon); if (drawable != null) drawable.setBounds(0, 0, size, size); return drawable; } }