I want to create two new custom buttons to use in my android application.
I want them to be like this:
So basically I will have a png image stored in my resources that will be the button's icon. I will have another image as a 9patch stretchable as the button background. I tried something but the result is hideous, so I must be doing something wrong.
This code:
<Button
android:layout_width="100px"
android:layout_height="100px"
android:drawableTop="@drawable/imgIcon"
android:drawablePadding="2px"
android:text="Text"
android:background="@drawable/button_background"
/>
Later Edit: If I make like suggested by Macarse bellow:
<Button android:id="@+id/yourid"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Your text here"
android:drawableTop="@drawable/imgdonetracks">
</Button>
I get like in first image
If I make this change:
<Button android:id="@+id/yourid"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Your text here"
android:drawableTop="@drawable/imgdonetracks"
android:background="@drawable/button_background">
</Button>
everything get's wrong
Check image http://img255.imageshack.us/i/android3.png/
<button android:id="@+id/yourid"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Your text here"
android:drawabletop="@drawable/[image]">
</button>
Here is the documentation: http://developer.android.com/reference/android/widget/TextView.html#attr_android:drawableTop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With