我正在制作一個應用程式,但我找不到任何解決方案。以下是我的代碼:
我正在制作一個應用程式,但我找不到任何解決方案。
<?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"/span>
android:layout_width="match_parent"/span>
android:layout_height="match_parent"/span>
tools:context=".MainActivity"。
android:background="@color/DarkGray"/span>
android:orientation="垂直">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"。
android:layout_height="match_parent"/span>
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"/span>
android:layout_height="wrap_content"/span>
android:orientation="垂直">
<LinearLayout
android:layout_width="match_parent"/span>
android:layout_height="wrap_content"/span>
android:background="@color/BackGroundColor"
android:orientation="horizontal"
android:paddingTop="4dp"/span>
android:paddingBottom="4dp">
<TextView
android:layout_width="0dp"/span>
android:layout_height="wrap_content"/span>
android:layout_weight="1"/span>
android:textAlignment="center"/span>
android:textAllCaps="true"/span>
android:textColor="@color/SecondaryTextColor"/span>
android:textSize="18sp"/span>
android:textStyle="bold" />
<TextView
android:layout_width="0dp"/span>
android:layout_height="wrap_content"/span>
android:layout_weight="1"/span>
android:textAlignment="center"/span>
android:textAllCaps="true"/span>
android:textColor="@color/SecondaryTextColor"/span>
android:textSize="18sp"/span>
android:textStyle="bold" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"。
android:layout_height="400dp"/span>
android:background="@color/BlueGray"
android:nestedScrollingEnabled="false"/>
<TextView
android:layout_width="match_parent"/span>
android:layout_height="wrap_content"/span>
android:background="@color/BackGroundColor"
android:padding="4dp"/span>
android:textAlignment="center"/span>
android:textColor="@color/PrimaryTextColor"。
android:textSize="22sp" />
<ListView
android:id="@ id/eventsListView"/span>
android:layout_width="match_parent"。
android:layout_height="match_parent"/span>
android:padding="2dp"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
我想實作的是在我的ListView里面添加CardViews,并且不僅能夠滾動ListView,而且能夠滾動整個視圖。我之前嘗試過RecyclerView,但那對我來說也不奏效。
我的想法是:
并且滾動整個事情,而不僅僅是ListView。
uj5u.com熱心網友回復:
你需要使用NestedScrollView.
。NestedScrollView就像ScrollView一樣,但是它支持在新舊版本的Android上同時充當嵌套滾動的父和子。嵌套滾動是默認啟用的。
別忘了在你的RecyclerView中添加recyclerView.setNestedScrollingEnabled(false);。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/315688.html
標籤:
下一篇:ScrollView不能彈出

