ListView внутри вложенного ConstraintLayouts не является прокруткой - PullRequest
0 голосов
/ 31 мая 2018

Это мой первый вопрос о переполнении стека.

Для моего макета требуется представление списка внизу экрана.Полный макет разработан в макете ограничения. Представление списка также помещается в макет ограничения. Однако это не прокрутка.

Это код, который пришел для исправления, поэтому я не могу сделать много изменений, чтобы заставить представление списка работать.

Некоторые могут подумать, что это дублирующий вопрос, но в представлении списка есть только 1 или 2 ответа с макетом ограничения, и решения тоже не помогли.Я много искал, но ничего не работает.

Любая помощь приветствуется.

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

        <android.support.constraint.ConstraintLayout
            android:id="@+id/cl_recent_memos_top_heading"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/gray">

                <ImageView
                    android:id="@+id/img_recent_memos_top_heading_bar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/space_10"
                    android:layout_marginLeft="@dimen/space_10"
                    android:layout_marginTop="@dimen/space_10"
                    android:src="@drawable/applied_leaves_top"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/tv_recent_top_heading_bar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/space_10"
                    android:layout_marginLeft="@dimen/space_10"
                    android:layout_marginTop="@dimen/space_10"
                    android:fontFamily="serif"
                    android:text="@string/recent"
                    android:textColor="@color/dark_gray"
                    android:textSize="@dimen/top_heading_first_label_text_size"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toRightOf="@id/img_recent_memos_top_heading_bar"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/tv_memos_top_heading_bar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/space_10"
                    android:layout_marginLeft="@dimen/space_10"
                    android:layout_marginTop="@dimen/space_13"
                    android:fontFamily="serif"
                    android:text="@string/memos"
                    android:textColor="#c5c5c5"
                    android:textSize="@dimen/top_heading_first_second_text_size"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toRightOf="@id/tv_recent_top_heading_bar"
                    app:layout_constraintTop_toTopOf="parent" />
            </android.support.constraint.ConstraintLayout>
        </android.support.constraint.ConstraintLayout>

        <android.support.constraint.ConstraintLayout
            android:id="@+id/cl_recent_memos_grid"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="0dp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cl_recent_memos_top_heading">

            <android.support.constraint.ConstraintLayout
                android:id="@+id/cl_recent_memos_grid_header"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/space_5"
                app:layout_constraintLeft_toLeftOf="parent">

                <android.support.constraint.ConstraintLayout
                    android:id="@+id/cl_container_header"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <android.support.constraint.ConstraintLayout
                        android:id="@+id/cl_memo"
                        android:layout_width="180dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/space_1"
                        android:background="#31cbe5"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toTopOf="parent">

                        <TextView
                            android:id="@+id/tv_memo"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:fontFamily="serif"
                            android:paddingLeft="@dimen/space_3"
                            android:text="@string/memo"
                            android:textColor="@color/white"
                            android:textSize="@dimen/show_applied_leave_grid_header_label_text_size"
                            app:layout_constraintLeft_toLeftOf="parent" />
                    </android.support.constraint.ConstraintLayout>

                    <android.support.constraint.ConstraintLayout
                        android:id="@+id/cl_memo_date"
                        android:layout_width="100dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/space_1"
                        android:background="#31cbe5"
                        app:layout_constraintLeft_toRightOf="@id/cl_memo">

                        <TextView
                            android:id="@+id/tv_memo_date"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:fontFamily="serif"
                            android:paddingLeft="@dimen/space_3"
                            android:text="@string/memo_date"
                            android:textColor="@color/white"
                            android:textSize="@dimen/show_applied_leave_grid_header_label_text_size" />
                    </android.support.constraint.ConstraintLayout>

                    <!-- To -->
                    <android.support.constraint.ConstraintLayout
                        android:id="@+id/cl_document"
                        android:layout_width="140dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/space_1"
                        android:background="#31cbe5"
                        android:paddingLeft="@dimen/space_3"
                        app:layout_constraintLeft_toRightOf="@id/cl_memo_date">

                        <TextView
                            android:id="@+id/tv_document"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:fontFamily="serif"
                            android:text="@string/document"
                            android:textColor="@color/white"
                            android:textSize="@dimen/show_applied_leave_grid_header_label_text_size" />
                    </android.support.constraint.ConstraintLayout>

                    <!-- Edit -->
                    <android.support.constraint.ConstraintLayout
                        android:id="@+id/cl_edit"
                        android:layout_width="50dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/space_1"
                        android:background="#31cbe5"
                        app:layout_constraintLeft_toRightOf="@+id/cl_document">

                        <TextView
                            android:id="@+id/tv_edit"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/edit"
                            android:textColor="#fff"
                            android:textSize="@dimen/show_applied_leave_grid_header_label_text_size" />

                    </android.support.constraint.ConstraintLayout>

                    <!-- Delete -->
                    <android.support.constraint.ConstraintLayout
                        android:id="@+id/cl_delete"
                        android:layout_width="50dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/space_1"
                        android:background="#31cbe5"
                        app:layout_constraintLeft_toRightOf="@+id/cl_edit">

                        <TextView
                            android:id="@+id/tv_delete"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/delete"
                            android:textColor="#fff"
                            android:textSize="@dimen/show_applied_leave_grid_header_label_text_size" />

                    </android.support.constraint.ConstraintLayout>

                </android.support.constraint.ConstraintLayout>

            </android.support.constraint.ConstraintLayout>

            <android.support.constraint.ConstraintLayout
                android:id="@+id/cl_recent_memo_list"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginLeft="@dimen/space_5"
                app:layout_constraintLeft_toLeftOf="parent"
               app:layout_constraintTop_toBottomOf="@id/cl_recent_memos_grid_header">

                <ListView
                    android:id="@+id/lv_recent_memos"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:divider="@android:color/transparent"
                    android:fadeScrollbars="false" />

            </android.support.constraint.ConstraintLayout>

        </android.support.constraint.ConstraintLayout>
    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>

1 Ответ

0 голосов
/ 21 декабря 2018

У меня была та же проблема, когда мой ListView не прокручивался внутри ConstraintLayout.Для меня решение было установить ListView на android:layout_height="0dp" с верхним и нижним ограничениями.

Пример

<ListView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_constraintTop_toBottomOf="@id/cl_recent_memos_grid_header"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    >
</ListView>

...