RelativeLayout在真实设备上显示不正确

时间:2014-03-10 16:57:57

标签: android xml android-layout relativelayout

我对Android RelativeLayout有疑问。我的布局在仿真器上完美运行,仿真器配置为LG Nexus4(屏幕,分辨率)。但是,如果我在真正的Nexus4上运行应用程序,它会出现严重错误,我不知道如何修复它们。

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainMenuLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/zeekedLogo"
        android:contentDescription="@string/logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="24dp"
        android:layout_marginRight="24dp"
        android:src="@drawable/badge" />

    <TextView
        android:id="@+id/textButtonPlay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="56dp"
        android:text="@string/menu_play"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textButtonResume"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textButtonPlay"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:text="@string/menu_resume"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textLabelLevel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/zeekedLogo"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="54dp"
        android:text="@string/menu_level"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textButtonSound"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/zeekedLogo"
        android:layout_marginLeft="24dp"
        android:text="@string/menu_sound_on"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

以下是相同布局的屏幕截图:

仿真器:

enter image description here

Nexus 4:

enter image description here

提前致谢!

1 个答案:

答案 0 :(得分:0)

在我的相对布局中添加背景颜色后,它在我的Nexus上运行。 4我所做的一切......我认为这很奇怪。但最后我很高兴它有效。

相关问题