I have the following code
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_search_background"
android:padding="8dp"
android:drawableStart="@drawable/info"
android:text="@string/msg_decode_notice"/>
It looks like this:
The problem is that the margin from the edge of the field to the icon differs from the margin from the icon to the text. How can I increase the indentation on the right without resorting to the ImageView + TextView? I try to make my layout as flat as possible
>Solution :
You can try using the android:drawablePadding
attribute to specify the padding between the drawable (the icon) and the text. You can also use the android:paddingStart
and android:paddingEnd
attributes to specify the padding of the text field.
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_search_background"
android:padding="8dp"
android:drawableStart="@drawable/info"
android:drawablePadding="16dp"
android:paddingStart="24dp"
android:text="@string/msg_decode_notice"/>