I have a form which has around 12/13 fields. I used a Scrollview
inside a constraint layout. Below is the hierarchy of the XML layout. The problem is, it doesn\
Two Steps
Keep layout height for scroll view zero
android:layout_height="0dp"
Again for scroll view
android:fillViewport="true"
Try adding bottom constraint to scrollview (eg: app:layout_constraintBottom_toBottomOf="parent"
)
and change android:layout_height="wrap_content" to android:layout_height="0dp"
In my case NestedScrollView
worked instead of ScrollView
.
Following is the snippet of my working layout: Please make sure that you haven't make any childview height to match parent(0 dp) inside constrianlayout also for scroll view android:fillViewport="true;
Ask me if any doubt Occur.
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/_90sdp"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/cvLayout"
android:animateLayoutChanges="true">
In my case NestedScrollView
worked instead of ScrollView
. Following is the snippet of my working layout:
<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_width="match_parent"
android:layout_height="match_parent">
<!-- Some Views Here -->
<android.support.v4.widget.NestedScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Some Views That can be Scrolled Here -->
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>