[英]How could I nest two RecyclerView in a ScrollView and disable scrollview's scroll
I have a activity like this: 我有这样的活动:
<?xml version="1.0" encoding="utf-8"?>
<com.hyqfx.recyclerviewtest.LockScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_1"
android:layout_width="match_parent"
android:layout_height="400dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_2"
android:layout_width="match_parent"
android:layout_height="400dp"/>
</LinearLayout>
</com.hyqfx.recyclerviewtest.LockScrollView>
and the LockScrollView like this: 和LockScrollView像这样:
public class LockScrollView extends ScrollView {
public LockScrollView(Context context) {
super(context);
}
public LockScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LockScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override public boolean onTouchEvent(MotionEvent ev) {
return false;
}
}
In this situation, the scrollview will no scroll first, but when the recyclerview scroll to the bottom, the parent scrollview work again. 在这种情况下,scrollview将不会首先滚动,但是当recyclerview滚动到底部时,父scrollview将再次工作。
But I want the scrollview do not work ever. 但是我希望scrollview永远无法工作。
Someone can help me? 有人可以帮我吗? thanks very much! 非常感谢!
use NestedScrollView
instead of ScrollView
使用NestedScrollView
而不是ScrollView
You can use this way either : Add this line to your recyclerView
xml view : 您可以使用以下方式之一:将这行添加到recyclerView
xml视图中:
android:nestedScrollingEnabled="false" 机器人:nestedScrollingEnabled = “假”
try it , recyclerview
will be smoothly scrolled with flexible height 尝试一下, recyclerview
将以灵活的高度平滑滚动
hope this helped . 希望这有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.