Original Problem description: textView in xml: [java] <TextView android: id = "@ + id/bookTitle" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_weight = "1" android: drawableLeft = "@ drawable/checkmark" android: gravity = "center_vertical" android: textStyle = "bold" android: textSize = "24dip" android: maxLines = "1" android: ellipsize = "end"/> as you can see in the program, I set DrawableLeft in xml. I want to change drawable in the code. Is there any way to use the code to set drawableLeft for textview? Solution: [java] public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom). The call method is as follows: 1. use [java] android: drawableLeft = "@ drawable/icon" 2. the code dynamically changes [java] Drawable drawable = getResources (). getDrawable (R. drawable. drawable); // This step must be done, otherwise it will not be displayed. drawable. setBounds (0, 0, drawable. getMinimumWidth (), drawable. getMinimumHeight (); myTextview. setCompoundDrawables (drawable, null, null); or refer to another function [java] public void setCompoundDrawablesWithIntrinsicBounds (Drawable left, Drawable top, Drawable right, Drawable bottom)