Reputation: 1213
The main idea is that the FrameLayout (Black) is centered and the LinearLayout (Red) aligns at the bottom. This works perfectly on my 4.x emulators and on my Galaxy Nexus. Like this:
In Eclipse ADT the layout previews look fine on all sizes. However when running this on a 2.1 emulator the FrameLayout (Black) seems shifted downwards.
I got the following layout:
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity" >
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<LinearLayout
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginBottom="70dp"
android:background="#000000" >
</LinearLayout>
</FrameLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_gravity="bottom|center"
android:background="#FF0000"
android:orientation="horizontal" >
</LinearLayout>
</merge>
Anyone got any idea whats causing this?
Upvotes: 0
Views: 152
Reputation: 3322
This should work:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<LinearLayout
android:layout_width="300dp"
android:layout_height="200dp"
android:background="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_gravity="bottom"
android:background="#FF0000" />
</LinearLayout>
Upvotes: 1