Android allows programmers to place images at all four corners of a TextView. For example, if you are creating a
field with a TextView and at same time you want to show that the field is editable, then developers will usually place
an edit icon near that field. Android provides us an interesting option called compound drawable for a TextView:
field with a TextView and at same time you want to show that the field is editable, then developers will usually place
an edit icon near that field. Android provides us an interesting option called compound drawable for a TextView:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextView | |
android:id="@+id/title" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerInParent="true" | |
android:drawablePadding="4dp" | |
android:drawableRight="@drawable/edit" | |
android:text="Hello world" | |
android:textSize="18dp" /> | |
You can set the drawable to any side of your TextView as follows: | |
android:drawableLeft="@drawable/edit" | |
android:drawableRight="@drawable/edit" | |
android:drawableTop="@drawable/edit" | |
android:drawableBottom="@drawable/edit" |
Comments :
Post a Comment