I need the texts to show at the bottom inside buttons In Android. used android:paddingBottom, but not working

StackOverflow https://stackoverflow.com/questions/23455589

  •  15-07-2023
  •  | 
  •  

문제

I need the texts to show at the bottom inside buttons, but its not working after using paddingBottom. they keep showing at the center, not moving at all. Any help would be really appreciable. Thank you

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/bakgrunn"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="center"
        android:src="@drawable/bakgrunnsbilde" />

    <Button
        android:id="@+id/button1"
        android:layout_width="179dp"
        android:layout_height="70dp"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="33dp"
        android:paddingBottom="2dp"
        android:text="Add a drink" />

    <Button
        android:id="@+id/button2"
        android:layout_width="179dp"
        android:layout_height="70dp"
        android:layout_alignParentRight="true"
        android:layout_marginTop="33dp"
        android:paddingBottom="2dp"
        android:text="Edit/delete drink" />

    <Button
        android:id="@+id/button3"
        android:layout_width="179dp"
        android:layout_height="70dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/button1"
        android:layout_marginTop="2dp"
        android:paddingBottom="2dp"
        android:text="Graph" />

    <Button
        android:id="@+id/button4"
        android:layout_width="179dp"
        android:layout_height="70dp"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/button2"
        android:layout_marginTop="2dp"
        android:paddingBottom="2dp"
        android:text="Profile" />

</RelativeLayout>

enter image description here

도움이 되었습니까?

해결책

Use gravity for your Buttons

android:gravity="bottom"

PaddingBottom will make text Farther from bottom edges

다른 팁

use

android:gravity="bottom"

.

 <Button
        android:id="@+id/button1"
        android:layout_width="179dp"
        android:layout_height="70dp"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="33dp"
        android:paddingBottom="2dp"
        android:text="Add a drink"
        android:gravity="bottom"
     />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top