问题
Friends,
I want to display a button in android like mentioned in screenshot.
Could anyone guide me through how to achieve this?
回答1:
There is the ImageButton which you can use for that.
But I'm not sure how to make the Text on the button look like the Text in your screenshot. I would simply create the image with the text and then use it for the ImageButton.
回答2:
Use a normal Butto with drawableLeft attribute. See my sample code:
<Button android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="Refresh"
android:drawableLeft="@drawable/ic_btn_refresh"
android:id="@+id/btn_refresh" />
回答3:
You could use 9-patch fot background. You can specify padding area there (bottom and right lines), so background will be stretchable while text will not cover image. :)
回答4:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/refresh"
android:text="Refresh"/>
来源:https://stackoverflow.com/questions/6253488/how-to-create-button-with-image-text