android - 由于 RecyclerView,Scrollview 在 CollapsingToolbarLayout 下方滚动
问题描述
我有一个详细的活动,在我的应用程序中显示游戏的详细信息。布局主要由CollapsingToolbarLayout
带有游戏封面的a和NestedScrollView
包含细节的a组成。布局是这样的:
并且像这样滚动:
布局的 XML 文件是:
<android.support.design.widget.CoordinatorLayout 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/game_detail_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.GameDetailActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<ImageView
android:id="@+id/toolbar_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/game_cover"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/scrim" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_game_detail" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@drawable/ic_favorite_border_black_24dp" />
</android.support.design.widget.CoordinatorLayout>
而且content_game_detail
是:
<android.support.v4.widget.NestedScrollView 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/game_detail_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activities.GameDetailActivity"
tools:showIn="@layout/activity_game_detail">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- There are 11 TextViews here for all the info -->
<android.support.v7.widget.RecyclerView
android:id="@+id/videos_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/simple_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/videos_lable" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
问题是:当摘要很长并且有视频可以添加项目时RecyclerView
,布局开始在展开的工具栏下方稍微滚动,如下所示:
我需要向下滚动视图以查看信息的顶部。测试,我将问题缩小到RecyclerView
. 当我删除它时,这个问题不会发生。似乎当将项目添加到时RecyclerView
,布局本身会向上滚动以进行补偿,但我找不到为什么会发生这种情况(而不是只是向下扩展视图),也找不到解决方法。有人有什么主意吗?
解决方案
推荐阅读
- angular - 角度表 - 列不是计算列的总计/汇总。只有在输入文本框中输入值时,总计才能正常工作
- qt - 使单击的 QListWidgetItem 无边框
- python - Python - 字典列表到 redis 列表
- python - 使用网络抓取从 Twitter 下载搜索结果
- javascript - 如何在下面的方法中用 log.error 替换 printStackTrace
- python - Pyinstaller 无法执行脚本 pyi_rth_pkgres
- machine-learning - LUIS 中匹配冲突的实体
- kubernetes - PersistentVolumeClaim 已删除,但我可以在 kube-controller-manager 中看到 pvc 配置失败的日志
- python - Py:函数之间传递实例的问题
- sql-server - 仅使用开始时间创建间隔