【发布时间】:2016-10-17 11:03:33
【问题描述】:
我有一个包含 ImageView 和 RecyclerView 的 Scrollview。 如果导航抽屉打开然后关闭 RecyclerView 自动滚动到顶部,如何停止?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollViewMain"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView_main_icons_line"
android:src="@drawable/main_line" />
...
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_activity_main_passenger_log"
android:paddingBottom="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
【问题讨论】:
-
将 RecyclerView 放入 ScrollView 根本不是一个好主意。通过使用这种结构,您可以很容易地遇到点击/滑动事件的麻烦。我的建议 - 改变你的设计
-
@TodorKostov 我不能,除了这个问题一切都很好,recyclerView 的高度是 wrap_content 所以可以把 recyclerview 放在滚动视图中
标签: android android-recyclerview scrollview