[英]Trouble with scroll in view (GridLayot + GridView)
我在下面的視圖中有一些滾動問題
<?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
不會崩潰
據了解,ScrollView組件僅需要一個孩子。 嘗試將包括GridLayout在內的所有內容包裝在一個LinearLayout中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.