2013-01-21 57 views
0

我在相對佈局中有3個線性佈局。它似乎在模擬器和物理設備上工作,但在Eclipse中它完全關閉。在Eclipse中無法正確顯示嵌套佈局

我不確定在我的代碼中是否存在一些錯誤,或者這是Eclipse的一些正常行爲。

的代碼是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" >  

<LinearLayout 
    android:id="@+id/header" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:gravity="center" 
    android:background="#E89745" 
    android:layout_alignParentTop="true" 
    android:layout_above="@+id/logins" 
    > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="header" 
     android:gravity="center" 
    /> 

</LinearLayout> 

<LinearLayout 
android:id="@+id/logins" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_centerInParent="true" 
android:background="#F7E7AB"> 

    <EditText 
     android:id="@+id/EditText01" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     /> 

    <EditText 
     android:id="@+id/EditText02" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     /> 

    <Button 
     android:id="@+id/Button01" 
     android:text="Button" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     /> 

</LinearLayout> 

<LinearLayout 
    android:id="@+id/footer" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:layout_below="@+id/logins" 
    android:layout_alignParentBottom="true" 
    android:background="#61A179" 
    android:gravity="center" 
    > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="footer" /> 

</LinearLayout> 
</RelativeLayout> 

它看起來像在Eclipse什麼:
What it looks like in Eclipse:
並在仿真器和設備上:
And in emulator and on device:

回答

1

通過簡單地複製 - 選擇提供的XML,這是我的進入Eclipse UI編輯器。

My rendition of the provided XML

我目前使用Eclipse V4.2.1和ADT v21.0.1。

我在想也許你運行的是ADT Eclipse插件的老版本,它會導致你一些問題。嘗試通過Eclipse幫助菜單更新它。

+0

謝謝你的迴應。我使用的是相同版本的ADT,但是Eclipse的舊版本(3.8)。我嘗試從developer.android.com下載ADT + Eclipse的新版本,但仍然使用相同版本的Eclipse。無論是否可以更新Eclipse的可移植版本? –

+0

我不認爲你可以從3.8升級到4.2,因爲它們是兩個不同的版本,即Indigo和Juno。但是我可能是錯的,我不記得當我搬到Juno時是否需要新安裝Eclipse。抱歉,我無法在該部門獲得更多幫助。 –