0

I used this button generator. http://angrytools.com/android/button/

Is there an easy way to add an icon to the left of the text.

The drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <corners
    android:radius="10dp"
    />
    <gradient
    android:angle="90"
    android:startColor="#cacaca"
    android:endColor="#FBFBFB"
    android:type="linear"
    />
    <padding
    android:left="50dp"
    android:top="0dp"
    android:right="0dp"
    android:bottom="0dp"
    />
    <size
    android:width="600dp"
    android:height="60dp"
    />
    <stroke
    android:width="2dp"
    android:color="#9f9f9f"
    />
</shape>

The button

<Button
    android:id="@+id/angry_btn"
    android:text="button"
    android:textColor="#000000"
    android:textSize="18sp"
    android:layout_width="600dp"
    android:layout_height="60dp"
    android:background="@drawable/buttonshape"
    android:shadowColor="#A4A4A4"
    android:shadowDx="2"
    android:shadowDy="3"
    android:shadowRadius="5"
/>
bman
  • 3,740
  • 9
  • 34
  • 40
  • 1
    I found the answer here. http://stackoverflow.com/questions/3634191/how-to-center-icon-and-text-in-a-android-button-with-width-set-to-fill-parent – bman Sep 26 '13 at 05:37

3 Answers3

4

Use android:drawableLeft attribute in the Button XML.

Maxim Efimov
  • 2,747
  • 1
  • 19
  • 25
  • 1
    I tried that but it was too far to the left, is there a way to center it with the text – bman Sep 26 '13 at 05:31
0

use 'android:drawableLeft="@drawable/userImage"' or 'android:drawableRight="@drawable/user_image"' in Button xml attribute

DjHacktorReborn
  • 2,908
  • 2
  • 20
  • 29
  • 2
    I tried that but it was too far to the left, is there a way to center it with the text – bman Sep 26 '13 at 05:31
0

Try this wount really fail

 <Button
        android:id="@+id/fab"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="@color/btn_registration_login"
        android:text="LOGIN"
        android:paddingLeft="125dp"
        android:paddingRight="125dp"
        android:textColor="@color/white"
        android:drawableRight="@drawable/ic_navigate_next_white_18dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"/>
Goodlife
  • 3,822
  • 2
  • 24
  • 23