如何从ScrollView内的RecyclerView移除焦点? [英] How to remove focus from RecyclerView inside ScrollView?
本文介绍了如何从ScrollView内的RecyclerView移除焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Scrollview,其中包含ImageView和RecyclerView. 如果打开了导航抽屉,则关闭了RecyclerView自动滚动到顶部,如何停止此操作?
I have a Scrollview which contains an ImageView and RecyclerView. if navigation drawer opened then closed the RecyclerView auto scrolling to top, How to stop this?
<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具有默认焦点.
This problem because of recyclerView has default focus.
解决方案
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
将android:descendantFocusability="blocksDescendants"
添加到您的scrollView的立即布局
Add android:descendantFocusability="blocksDescendants"
to your immediate layout of scrollView
这篇关于如何从ScrollView内的RecyclerView移除焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文