HOW TO ADD IMAGE IN BUTTON WITH TEXT IN ANDROID

Pravesh Singh

Total Post:101

Points:709
Posted by  Pravesh Singh
 812  View(s)
Ratings:
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" />


  1. Ankita Pandey

    Post:183

    Points:1285
    Re: How to add image in button with text in android

    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 :



Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!