Seb
Seb

Reputation: 3215

impossible to align button on bottom of the parent

So I have build a login layout and expect to have a button at the bottom of the screen.

The layout of the login is defined as below:

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black">

        <include
            android:id="@+id/login_button"
            layout="@layout/widget_large_button"
            bind:buttonTitle="@{@string/login}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Unfortunately, the button remain on top and I can't figure out why

enter image description here

Below is the code of the button

<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <data>
        <variable name="buttonTitle"  type="String"/>
    </data>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="25dp"
            android:layout_marginEnd="25dp"
            android:layout_marginBottom="16dp"
            android:background="@drawable/stripe_backgound_05"
            android:clickable="false"
            android:focusable="false"
            android:letterSpacing="0.5"
            android:paddingTop="25dp"
            android:paddingBottom="25dp"
            android:text="@{buttonTitle}"
            android:textAllCaps="true"
            android:textColor="@color/gainsboro_05"
            android:textSize="16sp"/>
    </FrameLayout>


</layout>

I am using include because this button will be used at different place and I do not want to redo the code every single time

Upvotes: 1

Views: 52

Answers (1)

Ben P.
Ben P.

Reputation: 54234

With <include> tags, all layout_ parameters are ignored unless you specify android:layout_width and android:layout_height. So add them to your include tag:

<include
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ... />

Upvotes: 1

Related Questions