Scrollview inside constraint layout does not scroll to the bottom of the parent constraint

前端 未结 10 1314
予麋鹿
予麋鹿 2020-12-03 02:34

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\

相关标签:
10条回答
  • 2020-12-03 03:30

    Two Steps

    1. Keep layout height for scroll view zero
      android:layout_height="0dp"

    2. Again for scroll view
      android:fillViewport="true"

    0 讨论(0)
  • 2020-12-03 03:31

    Try adding bottom constraint to scrollview (eg: app:layout_constraintBottom_toBottomOf="parent") and change android:layout_height="wrap_content" to android:layout_height="0dp"

    0 讨论(0)
  • 2020-12-03 03:32

    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">
    
    0 讨论(0)
  • 2020-12-03 03:33

    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>
    
    0 讨论(0)
提交回复
热议问题