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