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
  •  | 
  •  

Frage

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

War es hilfreich?

Lösung

Use gravity for your Buttons

android:gravity="bottom"

PaddingBottom will make text Farther from bottom edges

Andere Tipps

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"
     />
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top