setCompoundDrawablesRelativeWithIntrinsicBounds/android:drawableEnd - Add a Drawable to the End of Text, in a TextView, in Java

setCompoundDrawablesRelativeWithIntrinsicBounds - How to Add a Drawable to the end of Text, in a TextView, in Java

setCompoundDrawablesRelativeWithIntrinsicBounds was added in API Level 17
Related XML Attribute: android:drawableEnd

setCompoundDrawablesRelativeWithIntrinsicBounds (int start, int top, int end, int bottom)Sets the Drawables (if any) to appear to the start of, above, to the end 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.

1. Ensure to change the minSDKVersion to 17, or greater.


3. Add a drawable named myImage

4. Add the code below to the onCreate method. This will set a drawable to be drawn to the end of the text. 
    myTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,R.drawable.myImage,0);
5. Compile and run!