A Small Design tip: Compound Drawables.
A question by our reader
I designed a layout which worked perfectly well, but I updated to ADT 16 and the new Lint tool gave me a warning
"This tag and its children can be replaced by one
and a compound drawable."
In this article we’ll have a look at what they are and see how we can use them to simplify some of our layouts.
A quick dig through the documentation for TextView lead me to the setCompoundDrawableWithIntrinsicBounds() method which is a method of attaching drawables to a TextView. We can replace the LinearLayout and its two children with a single TextView:
How to use it:
<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/text" android:gravity="center"/>