android layout: This tag and its children can be replaced by one <TextView/> and a compound drawable
To expand on Romain Guy's answer, here is an example.
Before:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="My Compound Button" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/my_drawable" />
</LinearLayout>
After:
<TextView
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My Compound Button"
android:drawableRight="@drawable/my_drawable" android:padding="5dp" />
Merge the TextView
and the ImageView
into one, by using TextView's setCompoundDrawable*()
methods, or using android:drawableLeft
.
Thought I would try to get some extra puntos for this as well: you can add padding between the image and the text using android:drawablePadding
. https://stackoverflow.com/a/6671544/1224741