是的,它仍将填充空间,但不是显示列表,而是显示另一个视图.这是一个例子:
<FrameLayout
android:id="@+id/GLFrame"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
<TextView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@android:id/empty"
android:gravity="center_vertical|center_horizontal|center"
android:text="@string/no_songs_found"
android:textColor="#FFF"
android:textSize="20sp"
android:textStyle="bold" />
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/list"
android:cacheColorHint="#0000" />
Run Code Online (Sandbox Code Playgroud)
这里的关键是"@android:id/empty"和"@android:id/list"ids.这些告诉Android,如果列表为空,它应该显示列表或其他视图.