0

I have 3 Linear Layouts inside a Relative Layout. It seems to be working in emulator and on physical device, however in Eclipse it's completely off.

I am not sure whether there is some mistake in my code or this some normal behavior of Eclipse.

The code is:

<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>

What it looks like in Eclipse:
What it looks like in Eclipse:
And in emulator and on device:
And in emulator and on device:

4

1 回答 1

1

Simply by copy-pasting the provided XML, here's what I'm getting in the Eclipse UI Editor.

My rendition of the provided XML

I'm currently using Eclipse v4.2.1 and ADT v21.0.1.

I'm thinking perhaps you're running an older version of the ADT Eclipse plugin and it's causing you some issues. Try updating it via the Eclipse Help menu.

于 2013-01-21T19:10:25.093 回答