I've been working on my android calculator and i can't seem to insert an image instead of text on a button. For example sqrt I don't want to have sqrt written on my button i want the image of the symbol on it, the same goes for x^y and alot of others. I have my custom background of the button working just fine. Thank you for your help in advance :)
EDIT: Thats not what i wanted i did manage to get my custom button and thats fine. On my button since its a calculator button i have android:text on it saying sqrt. I want to remove that and insert another png on my button showing the symbol of the square root instead of that text. Thank you for quick responses.
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/imageName"/>
You can have both text and image (or no text) when using the attribute drawableTop
, drawableBottom
, drawableLeft
and drawableRight
.
And for positioning the image how you want, consider using: paddingTop
, paddingBottom
, paddingLeft
and paddingRight
.
You can do this by ImageButton:
<ImageButton
android:id="@+id/submitEmailButton"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="right" android:layout_marginRight="15dip"
android:background="@drawable/ic_submit" />
Here ic_submit is the image you want to show as a button.
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