This all goes down in the XML file with the button in question. This can also be accomplished dynamically (not shown.) Here is the excerpt from the xml file defining the button. The image should be located in the drawable folder. The image is called from android:drawable. Use drawableLeft, drawableRight, drawableTop, drawableBottom depending on how you want to place the image in relation to the text. Adjust the padding to suit your aesthetic.
<Button
android:layout_width="wrap_content"
android:text="Sample Text"
android:id="@+id/Button01"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/search"
android:drawablePadding="0px"
android:padding="0px">
</Button>
No comments:
Post a Comment