简体   繁体   中英

How to put button abover other and at the bottom android?

I would like to know how to put my three buttons at the bottom in the right order. Actually the three buttons are aligned but at the top.

Here is my xml code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
tools:context="com.example.siansa.MainActivity"
tools:ignore="MergeRootFrame">

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="@color/blue"
    android:text="@string/connexion"
    android:textColor="@color/white" />

<Button
    android:id="@+id/button2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/red"
    android:layout_gravity="bottom"
    android:text="@string/inscription"
    android:textColor="@color/white" />

    <Button
    android:id="@+id/button3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/gold"
    android:text="@string/guest"
               android:layout_gravity="bottom"
    android:textColor="@color/white" />

Did you try this in your XML?

android:layout_above="@+id/button"
android:layout_below="@+id/button"
android:layout_toLeftOf="@+id/button"
android:layout_toRightOf="@+id/button" 

Edit:

Or try:

android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM