Dynamically set the drawableLeft icon for the TextView control, and set the spacing, textviewdrawable
:
Important attributes:
TextView. setCompoundDrawablePadding (4); // you can specify the spacing between the image and text.
TextView. setPadding (-5, 0, 0, 0); // set the overall padding
Private TextView addDesc (String [] MemDescs, int I) {String MemDesc = MemDescs [I]; TextView textView = new TextView (this); textView. setText (MemDesc); // Add the image Drawable drawable = getResources () on the left (). getDrawable (R. drawable. gray_circle); drawable. setBounds (0, 0, drawable. getMinimumWidth (), drawable. getMinimumHeight (); textView. setCompoundDrawables (drawable, null, null); textView. setTextColor (getResources (). getColor (R. color. gray_textcolor_shen); textView. setCompoundDrawablePadding (4); // set the spacing between the image and text textView. setPadding (-5, 0, 0, 0); return textView ;}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.