由于某種原因,我的回收站視圖的最后一行被這樣切斷了,我無法進一步向下滾動。
回收站查看圖片
我有一個自定義配接器。如果我讓行高更小,我可以讓底部出現,但我希望行是那個高度。有沒有辦法讓回收站視圖進一步向下滾動以顯示最后一行?
我的自定義配接器的布局 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical" android:layout_width="match_parent"
android:layout_height = "wrap_content"
android:id="@ id/mainLayout">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding = "12dp">
<TextView
android:id="@ id/textViewID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@ id/textViewSubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="TextView"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintStart_toEndOf="@ id/textViewID"
app:layout_constraintTop_toTopOf="@ id/textViewID" />
<TextView
android:id="@ id/textViewLastmodified"
android:layout_width="182dp"
android:layout_height="23dp"
android:layout_marginTop="8dp"
android:text="Last Modified: "
app:layout_constraintStart_toStartOf="@ id/textViewSubject"
app:layout_constraintTop_toBottomOf="@ id/textViewSubject" />
<TextView
android:id="@ id/textViewDate"
android:layout_width="81dp"
android:layout_height="68dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:text="Created on: "
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
使用我的 recyclerview 對活動進行 XML 布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".ShowActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@ id/recyclerView2"
android:paddingTop="?attr/actionBarSize"
android:layout_width="409dp"
android:layout_height="729dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
uj5u.com熱心網友回復:
要解決此問題,您可以 1)將根視圖高度設定為match_parent和 2)將 recyclerview 的固定大小替換0dp為適合螢屏。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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" <!-- 1 -->
tools:context=".ShowActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@ id/recyclerView2"
android:paddingTop="?attr/actionBarSize"
android:layout_width="409dp"
android:layout_height="0dp" <!-- 2 -->
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/461097.html
標籤:安卓 安卓工作室 android-recyclerview
上一篇:GooglePlayAppBundleExplorer中“下載”選項卡與“交付”選項卡下的下載大小,哪個是實際用戶的下載大小?
