android应用程序在设备上的布局大不相同

android应用程序在设备上的布局大不相同,android,Android,我构建了一个简单的单屏安卓应用程序-它有edittext用户名、密码等框。这就是它在AVD/Eclipse中的外观: 然而,当我将其部署到我的HTC Evo 4G时,它看起来是这样的: 如果有必要,项目构建目标是Eclipse中的Android 4.0,但我的HTC Evo 4g运行的是Android 2.3.3。这是造成这种巨大差异的原因吗?布局不应该向后兼容吗 我刚刚意识到: 当我将设备旋转到横向视图时,我只看到电子邮件编辑文本,但当设备处于纵向视图时,我只看到密码编辑文本(如上图所示)

我构建了一个简单的单屏安卓应用程序-它有
edittext
用户名、密码等框。这就是它在AVD/Eclipse中的外观:

然而,当我将其部署到我的HTC Evo 4G时,它看起来是这样的:

如果有必要,项目构建目标是Eclipse中的Android 4.0,但我的HTC Evo 4g运行的是Android 2.3.3。这是造成这种巨大差异的原因吗?布局不应该向后兼容吗

我刚刚意识到:
当我将设备旋转到横向视图时,我只看到电子邮件编辑文本,但当设备处于纵向视图时,我只看到密码编辑文本(如上图所示)

这是我的main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >



    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="40dp"
        android:layout_weight="0.34"
        android:scaleType="center"
        android:src="@drawable/shift" />


    <TextView
        android:id="@+id/txtLogin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:text="@string/login"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <FrameLayout
        android:id="@+id/frameLayout1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/txtEmail"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="20dp"
            android:text="@string/email"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <EditText
            android:id="@+id/txtEmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="50dp"
            android:inputType="textEmailAddress" >            
        </EditText>        

        <TextView
            android:id="@+id/txtPass"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="120dp"
            android:text="@string/password"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:hint = "Email address" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="150dp"
            android:inputType="textPassword"            
            android:hint="Password"/>


        <Button
            android:id="@+id/btnLogin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="200dp"
            android:text="Login" />

        <requestFocus/>

    </FrameLayout>

</LinearLayout>

在进一步研究和修补UI XML后,我意识到问题在于我的大部分控件都在
框架布局中

现在,我不确定
framelayout
到底做了什么,但它似乎将所有控件堆叠在一起(并忽略了边距)。我之所以只能看到密码edittext,是因为它位于元素堆栈的顶部