我試圖在另一個線性佈局中嵌入線性佈局。我有地圖視圖。如果我在mapview之後放置嵌入式佈局,它不起作用。如果我把它放在它之前呢?爲什麼,我該怎麼做?嵌入在另一個線性佈局中的線性佈局
下面給出兩個文件:第一個失敗。第二個工程?我想要第一個。
<!--two files.
The first file does not work. The Check Boxes in an embeded linear layout is below the mapview. It only shows map view.
The second file works. The Check Boxes in an embeded linear layout is ABOVE the mapview.-->
<!-- FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE FILE ONE-->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#A971E5" >
<com.google.android.maps.MapView
android:id="@+id/mapWhenImClose"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0MbR34udiEJdnkplC1F7rK4ZxbSFzdRagCruFDA"/>
<!-- had this line but it said depreciated
android:enabled="true" -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/chkShowStreetView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/strShowStreetView" />
<CheckBox
android:id="@+id/chkShowSatelliteView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/strShowSatelliteView" />
</LinearLayout>
</LinearLayout>
<!--File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two File Two-->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#A971E5" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/chkShowStreetView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/strShowStreetView" />
<CheckBox
android:id="@+id/chkShowSatelliteView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/strShowSatelliteView" />
</LinearLayout>
<com.google.android.maps.MapView
android:id="@+id/mapWhenImClose"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0MbR34udiEJdnkplC1F7rK4ZxbSFzdRagCruFDA"/>
<!-- had this line but it said depreciated
android:enabled="true" -->
</LinearLayout>
邏輯上似乎'MapView'佔用了全因爲你哈哈ve'android:layout_height =「fill_parent」',並且它迫使LinearLayout離開屏幕的底部。如果將其高度設置爲'wrap_content',會發生什麼情況?或者把'MapView'放到它自己的'LinearLayout'中,將它的高度設置爲0dp,對於包含'CheckBoxes'的'LinearLayout'也是一樣的。然後在每個上設置'android:layout_weight'來分配一部分屏幕。 – Squonk
抱歉只是注意到了這個......我也在玩這個方法......我現在的主要目標是學習的不僅僅是獲得一些東西。 –