2011-11-21 56 views
0

完全不同的我建了一個簡單的,一旦屏幕Android應用程序 - 它有edittext盒的用戶名,密碼等,這是它的外觀在AVD /月蝕:佈局Android應用程序在設備上

enter image description here

然而,當我把它部署到我的HTC EVO 4G,這是它的外觀:

enter image description here

如果它的事項,項目建設目標是Android 4.0的在Eclipse中,但我的HTC EVO 4G正在運行, roid 2.3.3。這是造成這種劇烈的差異?不應該向後兼容佈局嗎?

我才意識到這一點:
當我轉動我的設備到橫向視圖,我只看到電子郵件的EditText,不過,當設備處於縱向,我只看到密碼的EditText(如上圖) 。

這裏是我的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> 

回答

0

經進一步研究,並與UI XML擺弄周圍,我意識到這個問題是我必須在framelayout我的大部分控制。

現在,我不確定framelayout究竟做了什麼,但似乎將所有控件疊加在一起(並忽略邊距)。我只能看到密碼編輯文本的原因是因爲它被放置在元素堆棧的頂部。