• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How can I force a button to be at the bottom of the screen?

Moreno17

Lurker
Dec 1, 2019
3
0
Hello all, I am trying to design an activity but I am having problems trrying to put the button at the bottom of the screen. ¿How can I do it?
This is my XML file:

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <TextView
        android:id="@+id/tvAViajar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="35dp"
        android:layout_marginTop="56dp"
        android:layout_marginEnd="56dp"
        android:layout_marginBottom="25dp"
        android:text="@string/actividades"
        android:textColor="@color/colorPrimaryDark"
        android:textSize="28sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tvDestinoViaje"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="35dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="56dp"
        android:text="@string/destinoActividad"
        android:textSize="22sp" />


    <EditText
        android:id="@+id/etDestinoViaje"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="35dp"
        android:layout_marginEnd="56dp"
        android:layout_marginBottom="12dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="@string/etdestinoActividad" />

    <TextView
        android:id="@+id/tvFechaViaje"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="35dp"
        android:layout_marginTop="6dp"
        android:layout_marginEnd="56dp"
        android:layout_marginBottom="5dp"
        android:text="@string/fechaActividad"
        android:textSize="22sp" />


    <EditText
        android:id="@+id/etFechaViaje"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="35dp"
        android:layout_marginEnd="56dp"
        android:layout_marginBottom="15dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="@string/etfechaActividad" />

    <TextView
        android:id="@+id/tvHoraViaje"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="35dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="56dp"
        android:layout_marginBottom="5dp"
        android:text="@string/horaActividad"
        android:textSize="22sp" />

    <EditText
        android:id="@+id/etHoraViaje"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="35dp"
        android:layout_marginEnd="56dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="@string/ethoraActividad" />

    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@drawable/ripple_effect_primary"
        android:text="@string/buscar_actividades"
        android:textColor="@color/white" />


</LinearLayout>

And this is how it looks like:

Captura.PNG


Thanks all.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones