java - 回收站视图上方的 CardView,滚动为 One
问题描述
我正在尝试在回收站视图上方放置一个卡片视图。我想滚动我的卡片视图和回收器视图。问题是,只有回收器视图在滚动,并且回收器视图的内容在大小上非常扭曲。这就是我想要实现的目标: 示例图片
这是我的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" />
将不胜感激任何建议。
解决方案
将您的recyclerview
andcardView
放入 a 中scrollView
,然后添加android:nestedScrollingEnabled="true"
recycerlview
<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>
推荐阅读
- mule - 执行 mule 批处理流时出现异常,例如无法通过提及文件的路径来删除对象存储中的文件
- axapta - 将 doc 文件保存为 word 模板
- javascript - X-editable ajax 不发送某些 id
- php - PHP 基础算术 + 类型转换 floatval intval
- video-streaming - 我需要什么配置才能实时流式传输 720p 音频?
- python - 将列表(多维数组)列表放入熊猫数据框列
- c++ - C++ std::shared_ptr,是否重载 operator= 以使用复制构造函数?
- mysql - Maria DB SQL 代码和存储过程给出不同的输出
- javascript - Initialize Slider in materialize css
- git - 用于显示 user.name 的 git 命令没有给出任何结果