gpt4 book ai didi

java - CardView 位于 Recycler View 上方,滚动为一个

转载 作者:行者123 更新时间:2023-12-02 01:37:52 25 4
gpt4 key购买 nike

我试图将卡片 View 放置在回收器 View 上方。我想将我的卡片 View 和回收器 View 作为一个滚动。问题是,只有回收器 View 在滚动,并且回收器 View 的内容在大小上相当扭曲。这就是我想要实现的目标: Example Image

这是我的 xml:

<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:id="@+id/frameLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeFragment">

<!-- TODO: Update blank fragment layout -->

<android.support.v7.widget.CardView

android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:isScrollContainer="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="9dp"
android:src="@drawable/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.v7.widget.CardView>


<android.support.v7.widget.RecyclerView
android:id="@+id/blogListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/cardView" />

非常感谢任何建议。

最佳答案

将您的 recyclerviewcardView 放入 scrollView 中,并添加 android:nestedScrollingEnabled="true"回收 View

 <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/frameLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- TODO: Update blank fragment layout -->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">


<android.support.v7.widget.CardView

android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:isScrollContainer="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="9dp"
android:src="@drawable/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.v7.widget.CardView>

<android.support.v7.widget.RecyclerView
android:id="@+id/blogListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:nestedScrollingEnabled="true"
app:layout_constraintTop_toBottomOf="@+id/cardView" />

</LinearLayout>

</android.support.v4.widget.NestedScrollView>

</android.support.constraint.ConstraintLayout>

关于java - CardView 位于 Recycler View 上方,滚动为一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54961800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com