How to align views at the bottom of the screen ?

How to align views at the bottom of the screen ?

Asked on December 14, 2018 in XML.
Add Comment


  • 3 Answer(s)

    To align views at the bottom of the screen, follow the statement:

         Simple way to have a ConstraintLayout and check the bottom of the view to the bottom of the ConstraintLayout with app:layout_constraintBottom_toBottomOf=”parent”

         FloatingActionButton be created and will regulate to the end and the bottom of the screen.

    <android.support.constraint.ConstraintLayout
      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:layout_height="match_parent"
      android:layout_width="match_parent">
     
    <android.support.design.widget.FloatingActionButton
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent" />
     
    </android.support.constraint.ConstraintLayout>
    

        After having the relative layout which fills the screen can be able to use android:layout_alignParentBottom to move the button to the bottom of the screen.

     

    Answered on December 14, 2018.
    Add Comment

    Get the answer:

        The RelativeLayout can overlay the ScrollView at the bottom of the page.

        By using a dynamically stretching FrameLayout :

    <ScrollView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="match_parent"
      android:layout_width="match_parent"
      android:fillViewport="true">
      <LinearLayout
        android:id="@+id/LinearLayout01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical">
           
            <!-- content goes here -->
            <!-- stretching frame layout, using layout_weight -->
        <FrameLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1">
        </FrameLayout>
     
            <!-- content fixated to the bottom of the screen -->
        <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal">
              <!-- your bottom content -->
        </LinearLayout>
      </LinearLayout>
    </ScrollView>
    
    Answered on December 14, 2018.
    Add Comment

    Take this solution:

        Own the initial linear layout by abiding the relative layout inward the linear layout:

    <LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
      <TextView android:text="welcome"
        android:id="@+id/TextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
      </TextView>
      <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <Button android:text="submit"
          android:id="@+id/Button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentRight="true">
        </Button>
        <EditText android:id="@+id/EditText"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_toLeftOf="@id/Button"
          android:layout_alignParentBottom="true">
        </EditText>
      </RelativeLayout>
    </LinearLayout>
    
    Answered on December 14, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.