我在 ScrollView 中创建 RecyclerView 和 ListView,我遇到了滚动问题。滚动是抽搐的(无法平滑滚动),我知道这是 ScrollView 中的 RecyclerView 的问题,因为布局滚动没有任何问题当滑动直到 ListView 存在但是一旦 RecyclerView 项目进入布局它开始 SCSS (只用手指滚动,当手指离开时没有适当的滚动)。这是xml中的代码
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/lv_home_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@color/colorWhite"
android:dividerHeight="0.5dp"
android:visibility="gone"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycleView"
android:background="@color/colorWhite">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</ScrollView>
最佳答案
沿同一轴滚动的嵌套 View 一直都是 在 Android 上有问题。最近谷歌添加了嵌套滚动 支持。为了在较旧的平台级别上使用它,您应该 使用支持库中的 View ,例如
NestedScrollView
和RecyclerView
。ListView 无法使用
wrap_content
作为其高度。你可以做 这与RecyclerView
如果你有最新版本的RecyclerView
支持库。此外,您已经在一个地方使用了RecyclerView
,您还不如单独使用它们。ListView 并不是真正意义上的“下拉列表”。也许您应该考虑使用
Spinner
。
关于android - 当 RecyclerView 在 ScrollView 中时布局抽动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37214160/