Issue
I have a button with xml background. And I want to put image on this button. It is not possible to put two backgrounds in one button. So, is there other way of putting image on my button while I have had a background yet? Below the code of my button:
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="15dp"
android:background="@drawable/readmore_back"
/>
Solution
you may use
<ImageButton
..
..
..
android:src="@drawable/image1"
/>
instead of
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="15dp"
android:background="@drawable/readmore_back"
/>
Or
if you want to set the image
to your existing Button
then use
android:drawableTop
,android:drawableBottom
,android:drawableLeft
,android:drawableRight
Answered By - Mr. Roshan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.