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