Home > DeveloperSection > Forums > How to add image in button with text in android
Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    February-27-2015 3:55 AM

 Android Android  Android Controls 
Ratings:


 1 Reply(s)
 492  View(s)
Rate this:

I want to add image in button with text my code is

<Button

        android:id="@+id/mybtn"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Ok" />




Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Supported
Posted on    February-27-2015 5:50 AM

You need to add drawableLeft or drawableRight in your xml file. It set icon on left, right top and bottom.

<Button      
android:id="@+id/mybtn"       
android:layout_width="wrap_content"       
android:drawableLeft="@drawable/ic_launcher"      
android:layout_height="wrap_content"
android:text="Ok"/>

It will look like :




Don't want to miss updates? Please click the below button!

Follow MindStick