我有一个水平的RecyclerView放在一个垂直的ScrollView中。布局内的所有内容都可以正常显示,并且它们可以按照我想要的方向滑动,而且滑动起来非常流畅。
唯一的问题是,RecyclerView位于ScrollView中的一些其他内容下面。当RecyclerView部分可见时,它会将RecyclerView底部与屏幕底部对齐,这意味着RecyclerView上面的内容被推出屏幕。
有人知道为什么会发生这种情况以及如何解决吗?
这是一个简单的布局,它实现了我刚才描述的效果。即使您不填充RecyclerView,它仍然会发生这种情况。
唯一的问题是,RecyclerView位于ScrollView中的一些其他内容下面。当RecyclerView部分可见时,它会将RecyclerView底部与屏幕底部对齐,这意味着RecyclerView上面的内容被推出屏幕。
有人知道为什么会发生这种情况以及如何解决吗?
这是一个简单的布局,它实现了我刚才描述的效果。即使您不填充RecyclerView,它仍然会发生这种情况。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#fff"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#000"/>
</LinearLayout>
</ScrollView>