我希望整个屏幕滚动,但目前只有我的回收器会滚动。尽管所有元素都放置在 ScrollView 内的线性布局中,但还是会发生这种情况。
有什么想法错误在哪里吗?这是相关代码。
<?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"
tools:context=".NoodleDetailActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/noodleImage"
android:layout_width="match_parent"
android:layout_height="200dp"
android:adjustViewBounds="false"
android:scaleType="centerCrop"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_bottom"
android:fontFamily="sans-serif-smallcaps"
android:hapticFeedbackEnabled="false"
android:padding="30dp"
android:text="TextView"
android:textSize="18sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/extras_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="#F2F2F2"
android:padding="0dp" />
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
这就是它的视觉效果。
最佳答案
发现:似乎最佳实践是将recyclerView设置为整个布局并使其包含多种 View 类型。 我不会使用嵌套 ScrollView 。
关于java - 当可滚动的 recyclerView 仅占手机屏幕的一半时,如何让 Activity 中的整个屏幕滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58235317/