我有两个嵌套的滚动视图。问题是,只有左侧视图滚动,而右侧不滚动。视图包含两组不同的项目,我希望它们彼此独立滚动。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/blue_faint"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:fillViewport="true"
android:scrollbars="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycer_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".50"/>
</android.support.v4.widget.NestedScrollView>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:fillViewport="true"
android:scrollbars="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".50"/>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
我在BottomSheetDialog中使用它们是这样的:
myDiaog = new BottomSheetDialog(this);
mDialog.setContentView(R.layout.dialog_content);
mRecycler_1 = mDialog.findViewById(R.id.recycler_1);
mRecycler_2 = mDialog.findViewById(R.id.recycler_2);
mRecycler_1.setAdapter(mAdapter);
mRecycler_2.setAdapter(mAdapter);
mRecycler_1.setLayoutManager(new LinearLayoutManager(this));
mRecycler_2.setLayoutManager(new LinearLayoutManager(this));
mRecycler_1.setHasFixedSize(false);
mRecycler_1.setHasFixedSize(false);
mDialog.show()