我想配置我的按鈕佈局,並且無法正確形成結構。當我在VM上運行代碼時,儘管重量僅爲10%,ImageButton廣告佔據了屏幕的50%。每個圖像按鈕引用一個存儲在drawable-ldpi中的圖像,每個圖像大小約爲1 KB,活動代碼基本沒有添加,這是純粹的圖形界面,此時通過主要的xml。如何讓線性佈局中的我的體重正確對齊按鈕?
INTENDED佈局:
_______________________
| logo |
|______________________|
| search |
|______________________|
| |
| featured |
| |
|______________________|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
|____|_____|_____|_____|
| advertisement |
|______________________|
ANDROID的main.xml代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/toplayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="45"
android:gravity="top"
android:orientation="vertical" >
<ImageButton
android:id="@+id/mytastelogo"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="15"
android:src="@drawable/mytastelogo_image" />
<ImageButton
android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="10" />
<ImageButton
android:id="@+id/featuredpanel"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="20" />
</LinearLayout>
<LinearLayout
android:id="@+id/bottomlayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="45"
android:gravity="bottom"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/mycollection"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/mycollection_image" />
<ImageButton
android:id="@+id/myrecommendations"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/myrecommendations_image" />
<ImageButton
android:id="@+id/topitems"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/topitems_image" />
<ImageButton
android:id="@+id/randomitem"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/randomitem_image" />
</LinearLayout>
<LinearLayout
android:id="@+id/adlayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="10"
android:gravity="end" >
<ImageButton
android:id="@+id/advertisement"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
謝謝!這似乎完成了這項工作。 – jrquick