Проблема с прокруткой в ​​поле зрения (GridLayot + GridView) - PullRequest
1 голос
/ 11 марта 2019

У меня есть некоторые проблемы с прокруткой в ​​следующем представлении

<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:isScrollContainer="true">

    <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/mainGrid"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:columnCount="3"
                android:layout_margin="0dp"
                android:orientation="horizontal"
                android:layout_marginBottom="4dp">

        <!-- Card number block start -->
        <TextView
                android:layout_columnSpan="2"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:hint="Card number"/>
        <!-- Card number block end -->

        <!-- same other blocks -->

        <!-- Contact list block start -->
        <GridView
                android:layout_columnSpan="3"
                android:id="@+id/tableContacts"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="fill"
                tools:ignore="MissingConstraints"
                app:layout_constraintTop_toBottomOf="@+id/btnAddNewContact"/>
        <!-- Contact list block end -->

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

Если имеется длинный список контактов, то представление не прокручивается.Если я вставлю GridLayout внутрь ScrollView, то GridView сворачивается в одну строку и добавляется внутренняя прокрутка.

android:isScrollContainer="true" не помогло.

У меня просто естьнет вариантов, как добавить прокрутку, чтобы GridView не свернулся

1 Ответ

0 голосов
/ 11 марта 2019

Насколько известно, для компонента ScrollView требуется только один дочерний элемент. Попробуйте обернуть все, включая ваш GridLayout, в один LinearLayout.

...