Answer the question
In order to leave comments, you need to log in
How to make drawable centered in button android?
There is a button that takes up half the screen height, you need to insert an icon into it so that it is centered along with the text in the middle of the screen.
<Button
android:id="@+id/readBtn"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/read_btn_selector"
android:drawableTop="@drawable/read"
android:gravity="center"
android:onClick="readBtnClick"
android:text="@string/read_btn"
android:textColor="#ffffff" />
Answer the question
In order to leave comments, you need to log in
I recently searched for the answer to this question, but did not find it.
Did so
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/myButton"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/selector_bottom_buttons"
>
<ImageView
android:id="@+id/myButton_Image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:contentDescription="@string/text_btnKill"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
/>
<TextView
android:id="@+id/myButton_Text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Kill"
/>
</FrameLayout>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question