- 解决NestedScrollView 嵌套 RecyclerVi
- NestedScrollView嵌套RecyclerView导致
- NestedScrollView进入界面不能定位到顶部问题解决
- NestedScrollView+RecyclerView
- android的RecyclerView嵌套在NestedScr
- android解决RecyclerView嵌套在NestedSc
- NestedScrollView 嵌套 RecyclerView
- NestedScrollView嵌套Recyclerview列表
- 解决 NestedScrollView 嵌套 RecyclerV
- ScrollVIew嵌套RecycleView不显示的问题
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
tools:context="com.zhongxin.nestscrolledview.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
代码如下
public class MainActivity extends AppCompatActivity {
private NestedScrollView scrollView;
private RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scrollView = (NestedScrollView) findViewById(R.id.scrollView);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new DemoAdapter(this));
recyclerView.setNestedScrollingEnabled(false);
}
}
注意:setNestedScrollingEnabled该方法调用 设置为false即可实现嵌套的,NestedScrollView是专门为了兼容Mc design控件而生的


网友评论