Android ScrollView的RecyclerView部分
我有一个RecyclerView作为底部视图,在顶部还有一些其他视图: 我想滚动整个视图(1),而不仅仅是RecyclerView(2) 我已经设法让它发挥作用,但并非完美无缺。XML:Android ScrollView的RecyclerView部分,android,xml,xamarin,Android,Xml,Xamarin,我有一个RecyclerView作为底部视图,在顶部还有一些其他视图: 我想滚动整个视图(1),而不仅仅是RecyclerView(2) 我已经设法让它发挥作用,但并非完美无缺。XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
...
<View
style="@style/Divider"
android:layout_marginBottom="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewNote"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
...
两个问题:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
我试过你的例子 在
recyclerview
中滚动并不顺畅,因为当我
抬起我的手指,滚动停止了。无加速滚动,或
不管你叫它什么
连我都注意到了。我认为使用嵌套滚动时有一些限制,因为它必须处理两个滚动
当我从回收视图中删除项目时,其高度保持不变
相同的这意味着我有空的空间,图像曾经是
空白是因为填充
应用于回收视图
的线性布局
。事件虽然您删除了回收中的所有项目查看父级线性布局的填充保持不变,空白也保持不变。但是我得到了不想要的行为。将其保持在相对内部而不是线性布局内部如果您确定这行得通,您可以提供完整的布局吗?我现在倒过来:)是的,看起来是个很简单的问题。我将尝试使用许多其他可用视图中的一些。也许我还需要覆盖一些滚动行为。@raze Yes。那么空白区呢。这是我在回答中解释的情况吗?不,那没有帮助。视图的高度仍然与图像的高度相同,即使我已包装内容并删除了填充。需要以某种方式刷新布局。@raze从中删除项目后,您是否在recyclerview adapter
上使用了notifyDataSetChanged()
?如果没有,则使用itI使用NotifyItemRemoved(位置)。资源较少,并附带动画。它适用于我拥有的其他recyclerviews。我也有同样的问题,我从服务器获取recycler的数据,我已经检查过,recycler不平滑的原因是它在滚动视图中,一次从服务器获取所有图像,并且不可见项!我还没有任何解决方案,你有吗?!