setCompoundDrawablesWithIntrinsicBounds - How to Add a Drawable Below a TextView
setCompoundDrawablesWithIntrinsicBounds was added in API Level 3
Related XML Attribute: android:drawableBottom
setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom)
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.
The drawable (image, picture, etc) will be displayed centered, below the text
Related XML Attribute: android:drawableBottom
setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom)
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.
The drawable (image, picture, etc) will be displayed centered, below the text
1. Ensure to change the minSDKVersion to 3, or greater.
4. Add the code below to the onCreate method.
myTextView.setCompoundDrawablesWithIntrinsicBounds(0,0,0,R.drawable.myImage);
5. Compile and run!
Related Articles: