center image inside button

developer dev

i have this code for displaying an image on a button.

How to position the image so that it doesn't touch the frame/border?

this the code:

 <Button
                android:layout_width="0dp"
                android:layout_weight="0.45"
                android:onClick="EXIT"
                android:layout_height="95dp"
                android:text="Exit"
                android:textSize="22sp"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:background="@drawable/buttonnew"
                android:textStyle="bold"
                android:drawableTop="@drawable/zexit"
                android:textColor="#000000"
                android:layout_gravity="bottom"
                />

enter image description here

Michael Fourre

Since you are referring to the Button rather than the drawable, it would be best to use padding instead of margin, e.g. android:paddingTop

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Center a button inside a DIV

From Dev

Center image inside parent

From Dev

Center Image inside LinearLayout with weight

From Dev

Not able to center the image inside a div

From Dev

Center image inside div horizontally

From Dev

Center an image inside another image in Bootstrap

From Dev

How to center icon and text inside of a button?

From Dev

How to center the text inside a Button regardless of drawableLeft?

From Dev

how to center the button inside a table cell

From Dev

How to center align ion icon inside button?

From Dev

How to vertically center a button and text inside a div

From Dev

Button does not center inside RelativeLayout that have gravity=center

From Dev

Center span inside a div container over an image

From Dev

How to center image inside grid col?

From Dev

Center image based on size inside div with whitespace

From Dev

Vertical center div inside another div + image

From Dev

How to vertically center an image inside a SPAN

From Dev

center horizontally a clickable image inside a div

From Dev

How to center text inside background image?

From Dev

center image vertically inside a smaller div

From Dev

How to center image and text inside a block

From Dev

center horizontally a clickable image inside a div

From Dev

Image at center of ImageView inside Nested LinearLayout

From Dev

Center align image inside div horizontally and vertically

From Dev

Div with aspect ratio - how to center image inside of it?

From Dev

How to center image inside a div, using CSS?

From Dev

Android - Rotate image inside the button

From Dev

Align text and image inside button

From Dev

UWP Image overflow inside button

Related Related

HotTag

Archive