我有一个关于Recyclerview用法的问题。在nestedscrollview中添加recyclerview时,它会展开,但在nestedscrollview中添加listview时,它不会展开。在“多个回收服务”视图中,也可以在“多个回收服务”视图中展开。listview和recyclerview的区别是什么?
例子:
<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:fillViewport="true"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/myrecycleview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:scrollbars="vertical"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My Button"/>
</LinearLayout>
<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:fillViewport="true"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical">
<ListView
android:id="@+id/mylistview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:scrollbars="vertical"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My Button"/>
</LinearLayout>
这里的按钮不可见。