0

I am using a NestedScrollView to scroll elements when in landscape mode. However, the bottom elements are cutting off. I have tried using fillViewPort as true, padding bottom, but did not achieve anything.

How do we make the view scroll using a NestedScrollView containing a Constrained Layout as its child?

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fillViewport="true"
    tools:context="com.MainActivity"
    xmlns:android="http://schemas.android.com/apk/res/android"
    >


<android.support.constraint.ConstraintLayout android:layout_width="match_parent"
    android:layout_height="wrap_content"

>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayout23"
        android:layout_width="325dp"
        android:layout_height="54dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="40dp"
        app:layout_constraintBottom_toTopOf="@+id/textInputLayout22"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.526"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"
        app:layout_constraintVertical_chainStyle="packed">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/firstName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hintFirstName"
            android:inputType="text" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayout22"
        android:layout_width="325dp"
        android:layout_height="54dp"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toTopOf="@+id/textInputLayout24"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout23">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/lastName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hintLastName"
            android:inputType="text" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayout24"
        android:layout_width="325dp"
        android:layout_height="54dp"
        app:layout_constraintBottom_toTopOf="@+id/textInputLayout25"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout22">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/age"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hintAge"
            android:inputType="numberDecimal" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayout25"
        android:layout_width="325dp"
        android:layout_height="54dp"
        app:layout_constraintBottom_toTopOf="@+id/textInputLayout26"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout24">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hintEmail"
            android:inputType="textEmailAddress" />
    </android.support.design.widget.TextInputLayout>


    <android.support.design.widget.TextInputLayout
        android:id="@+id/textInputLayout26"
        android:layout_width="325dp"
        android:layout_height="54dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout25">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/phone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hintPhone"
            android:inputType="phone" />
    </android.support.design.widget.TextInputLayout>

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onMajorSelection"
        android:text="@string/major"
        app:layout_constraintEnd_toStartOf="@+id/majorSelected"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintStart_toStartOf="@+id/textInputLayout26"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout26" />

    <TextView
        android:id="@+id/majorSelected"
        android:layout_width="200dp"
        android:layout_height="52dp"
        android:focusable="false"
        android:gravity="center_vertical"
        android:hint="@string/hintSelectedMajor"
        android:inputType="none"
        app:layout_constraintBottom_toBottomOf="@+id/button"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/button" />

    <Button
        android:id="@+id/saveButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="52dp"
        android:onClick="save"
        android:text="@string/done"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/resetButton"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintStart_toStartOf="@+id/button"
        app:layout_constraintTop_toBottomOf="@+id/button"
        app:layout_constraintVertical_bias="0.057" />

    <Button
        android:id="@+id/resetButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:onClick="reset"
        android:text="@string/reset"
        app:layout_constraintBottom_toBottomOf="@+id/saveButton"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/saveButton"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout26"
        app:layout_constraintVertical_bias="1.0" />

    <Button
        android:id="@+id/removeMajor"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@android:drawable/ic_delete"
        android:onClick="onDeleteMajor"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="@+id/majorSelected"
        app:layout_constraintTop_toTopOf="@+id/majorSelected" />

</android.support.constraint.ConstraintLayout>

</android.support.v4.widget.NestedScrollView>
abjee
  • 1
  • 1
  • Possible duplicate of [NestedScrollView and CoordinatorLayout. Issue on Scrolling](https://stackoverflow.com/questions/30806119/nestedscrollview-and-coordinatorlayout-issue-on-scrolling) – krishank Tripathi Feb 09 '18 at 05:08
  • I tried those approaches but it did not help. There is a weird thing going on, in landscape mode once I enter data in the first field, it starts scrolling perfectly. It won't scroll before that – abjee Feb 09 '18 at 05:28
  • add this line in you manifest below in which activity this is happening android:configChanges="orientation|screenSize" – krishank Tripathi Feb 09 '18 at 05:46
  • Awesome! That worked for me! Thanks a lot – abjee Feb 09 '18 at 19:13
  • If it worked please upvote for check right my answer – krishank Tripathi Feb 10 '18 at 05:26

0 Answers0