我正在努力使用我的Android佈局。在列表視圖下放置片段
我想創建一個線性佈局,其中包含頂部的按鈕,下一個列表視圖,並且當顯示列表視圖的所有元素時,我想顯示顯示Google地圖的片段。
這是我的Layout xml文件。在這種情況下,你只能看到片段和按鈕,但不是列表視圖
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="vertical"
tools:context="de.mypackage.MyActivity">
<Button
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0"
android:id="@+id/button_back"
android:text="@string/back"
/>
<ListView
android:id="@+id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1"/>
/>
<fragment
android:id="@+id/fragement"
android:name="de.mpackage.MapsFragment"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0"
tools:layout="@layout/fragment_maps"/>
</LinearLayout>
任何想法我如何能實現我的佈局?
增加
layout_weight=1
你可以添加片段作爲註腳到ListView? – raktale將標題添加到將保存按鈕的列表視圖中。將頁腳添加到您的列表視圖中,該視圖將保存Google地圖。 – nnn
@MichaelMeyer我嘗試使用'wrapper_content'作爲'ListView',並將'layout_weight = 1'放入'fragment'中。我發佈了答案。希望能幫助到你。 :) – natsumiyu