我理解起来有些困难setHasFixedSize().我知道,当RecyclerView文档中的大小不变时,它用于优化.
这意味着什么?在大多数常见情况下,ListView几乎总是具有固定的大小.在什么情况下它不是固定的大小?这是否意味着它在屏幕上占据的实际房地产随着内容的增长而增长?
我创建了一个带有页面的应用程序,需要从Web服务动态加载内容.我希望listview能够与NestedScrollView中的线性布局一起滚动.但是当内容加载到列表视图时,它不会延伸到其完整高度.
这是我的代码.
<?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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.myquestionth.myquestionth10.Profile2Activity"
tools:showIn="@layout/activity_profile2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#BBBBBB" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Media heading"
android:id="@+id/textView2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis."
android:id="@+id/textView8" />
</LinearLayout>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#70bcf5" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
我有一些关于scrollview的搜索无法嵌套.根据我在Google Play评论页面设计的布局,这是我想要的一个例子.他们使用的方法是什么?建议我,如果我做错了什么.非常感谢.
这就是我想要的.