Android按钮布局 - 无法正确显示

时间:2011-11-19 20:22:05

标签: android xml layout imagebutton

我想在我的Android应用的“欢迎屏幕”上显示三张图片。只显示了其中一个图像,我无法弄清楚为什么......任何帮助?

XML文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@drawable/main_bg"
> 
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:paddingTop="30dip"
    android:layout_height="wrap_content"
    android:gravity="center"
    >

        <ImageButton
            android:id="@+id/mnwvbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="15dip"
            android:background="@drawable/mnwvicon" />

        <ImageButton
            android:id="@+id/reportsbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/reportsicon" />

    </LinearLayout>

    <ImageButton
        android:id="@+id/mnwvshowbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/showicon"
        android:paddingTop="30dip" />

</LinearLayout>

我在另一个应用程序中设置完全相同,所以我不知道它为什么不在这里工作?

3 个答案:

答案 0 :(得分:0)

我认为它是因为最后一个图像在内部线性布局之外,所以把它放在内部线性布局中,你应该能够连续看到所有三个图像。

答案 1 :(得分:0)

尝试使用属性android:ScaleType =“center”在ImageButton中缩放图像 或尝试使用不同的布局,如Tablayout,以适当的间距排列行和列中的图像。

答案 2 :(得分:0)

对不起伙计们。我没有应用程序支持不同的屏幕尺寸。我不确定为什么这很重要,但是一旦我加入了支持,那就完美了!谢谢你的意见!有人知道为什么这很重要吗?我不知道为什么支持屏幕尺寸很重要?