我正在尝试配置我的按钮布局,尽管没有错误,但无法弄清楚为什么按钮不可见。我已经修修补补,充其量只能得到一个按钮来显示更少的所有按钮。每个图像按钮都引用存储在 drawable-ldpi 中的图像,每个图像的大小大约为 1 KB。
下面是预期的布局外观:
_______________________
| 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" >
<LinearLayout
android:id="@+id/toplayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="45" >
<ImageButton
android:id="@+id/mytastelogo"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:src="@drawable/mytastelogo_image" />
<ImageButton
android:id="@+id/search"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="10" />
<ImageButton
android:id="@+id/featuredpanel"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="20" />
</LinearLayout>
<LinearLayout
android:id="@+id/bottomlayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="45" >
<ImageButton
android:id="@+id/mycollection"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/mycollection_image" />
<ImageButton
android:id="@+id/myrecommendations"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/myrecommendations_image" />
<ImageButton
android:id="@+id/topitems"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/topitems_image" />
<ImageButton
android:id="@+id/randomitem"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="@drawable/randomitem_image" />
</LinearLayout>
<ImageButton
android:id="@+id/advertisement"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10" />
</LinearLayout>
最佳答案
您已将高度和宽度设置为 0 dps。你什么也看不到。尝试先解决那些 0dps。
关于android - 我不明白为什么我的按钮没有出现在我的 Android VM 上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12065397/