解决ScrollView嵌套RecyclerView无法滑动问题

问题描述:

界面布局嵌套关系: ViewPager -> ScrollView -> FrameLayout -> RecyclerView

界面设置固定高度可滑动,自适应的话无法滑动 

解决方法:

对RecyclerView外层进行RelativeLayout包裹

重写LayoutManager 代码设置自定义manager

mRecyclerView.setHasFixedSize(true);

// use a linear layout manager

mLayoutManager = new LinearLayoutManager(getContext()); 

 mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); 

 mRecyclerView.setLayoutManager(mLayoutManager); 

 // Disabled nested scrolling since Parent scrollview will scroll the content. 

 mRecyclerView.setNestedScrollingEnabled(false); 

 // specify an adapter (see also next example) 

 mAdapter = new SimpleListAdapter(DataSetProvider.generateDataset()); mRecyclerView.setAdapter(mAdapter);


重写LayoutManager地址: LayoutManager

此方法虽然解决滑动问题,但是加载时item会一次性全部加载

你可能感兴趣的:(解决ScrollView嵌套RecyclerView无法滑动问题)