1

I have some problems with the scroll in the following view

<?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>

If there is a long contact list, then the view is not scrollable. If I insert GridLayout inside ScrollView, then GridView is collapsed to one line and an inner scroll is added.

android:isScrollContainer="true" didn't help.

I just have no options for how to add scrolling so that GridView doesn’t collapsing

gian1200
  • 3,670
  • 2
  • 30
  • 59
DarkVss
  • 75
  • 7
  • Try to see if this solution (using ScrollView on LinearLayout) applies to GridLayout too: https://stackoverflow.com/questions/4055537/how-do-you-make-a-linearlayout-scrollable – acarlstein Mar 11 '19 at 14:26
  • Someone already asked this question in StackOverflow. Here is the link: https://stackoverflow.com/questions/10610943/gridlayout-scrollview – acarlstein Mar 11 '19 at 14:30
  • @acarlstein first- look on down post , second - you are inattentive, structure is more complicated and because of this there is a problem – DarkVss Mar 12 '19 at 06:52
  • so... you tried ```...``` and it didn't work. Is that what you are saying. – acarlstein Mar 12 '19 at 12:48
  • Find [solution trouble](https://stackoverflow.com/questions/18367522/android-list-view-inside-a-scroll-view#answer-19311197). This is work for me – DarkVss Mar 14 '19 at 13:35

1 Answers1

0

As far as know the ScrollView component requires one child only. Try wrapping everything including your GridLayout in one LinearLayout.

Ryan Godlonton-Shaw
  • 584
  • 1
  • 5
  • 18
  • its doesnt work i tried allready - scroll->linear->block*n and scroll->linear->(linear->block)*n – DarkVss Mar 11 '19 at 14:52