我正在尝试配置我的按钮布局,但无法正确形成结构。当我在 VM 上运行代码时,它使 ImageButton 广告占据了屏幕的 50% 以上,尽管重量仅为 10%。每个图像按钮引用一个存储在 drawable-ldpi 中的图像,每个大小约为 1 KB,并且活动代码是基本的,没有添加,这目前是通过主 xml 的纯图形界面。
预期布局:
_______________________
| 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>