我想在屏幕上有兩個相對佈局。一個在下面。我做了這段代碼,但它不起作用。在這種情況下,我只能看到兩個上面的相對佈局insted,這個佈局佔用了整個空間,儘管我設置了wrap_content。一個屏幕上的兩個相對佈局
編輯!:我把下面的第二個代碼也失敗了。
編輯2!:我發現問題......這有點...傷心。問題在於我的主題。我將背景設置爲太大的png文件,當我通過清單應用默認主題時,發生這種情況。當我刪除它一切都很好。
此版本也失敗。
新代碼:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/some_id"
android:layout_above="@+id/some_id2"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/main_button_localize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_localize" />
</RelativeLayout>
<RelativeLayout
android:id="@id/some_id2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<ToggleButton
android:id="@+id/main_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
舊代碼:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/maps_manager_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<!-- Top -->
<Button
android:id="@+id/maps_manager_top_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/empty" />
<Button
android:id="@+id/maps_manager_top_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/maps_manager_top_left"
android:contentDescription="@string/empty" />
<Button
android:id="@+id/maps_manager_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/maps_manager_top_middle"
android:contentDescription="@string/empty" />
<!-- Middle -->
<Button
android:id="@+id/maps_manager_middle_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/maps_manager_top_left"
android:contentDescription="@string/empty" />
<Button
android:id="@+id/maps_manager_middle_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/maps_manager_middle_left"
android:layout_below="@id/maps_manager_top_middle"
android:contentDescription="@string/empty" />
<Button
android:id="@+id/maps_manager_middle_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/maps_manager_middle_middle"
android:layout_below="@id/maps_manager_top_right"
android:contentDescription="@string/empty" />
<!-- Bottom -->
<Button
android:id="@+id/maps_manager_bottom_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/maps_manager_middle_left"
android:contentDescription="@string/empty" />
<Button
android:id="@+id/maps_manager_bottom_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/maps_manager_bottom_left"
android:layout_below="@id/maps_manager_middle_middle"
android:contentDescription="@string/empty" />
<Button
android:id="@+id/maps_manager_bottom_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/maps_manager_bottom_middle"
android:layout_below="@id/maps_manager_middle_right"
android:contentDescription="@string/empty" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/maps_manager_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="true"
android:layout_below="@id/maps_manager_menu" >
<ToggleButton
android:id="@+id/maps_manager_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
我檢查Eclipse的,我能看到兩個相對佈局一個在另一個之下。 –
在第二個相對佈局中將match_parent更改爲wrap_content –
android:layout_alignBottom =「true」android:layout_alignParentBottom =「true」 – mukesh