Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference in android layout designs between versions 2.3.3 and 4+

I'm facing a strange issue in my project when creating a simple xml design as follow:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="#FF0000"
    android:layout_marginLeft="30dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button" 
        android:layout_gravity="left|center_vertical"/>

Now see the difference, this is the view in 4.2.2 :

2.3.3 version

And this one in 2.3.3:

enter image description here

Would appreciate if someone can help me with it. thanks

like image 850
Udi Oshi Avatar asked Apr 22 '13 14:04

Udi Oshi


Video Answer


1 Answers

It works, if you change it to this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:layout_marginLeft="30dp"
    android:background="#FF0000"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="New Button" />

</LinearLayout>

(I think I know why it behaves like this, let me just check something. I'll add an explanation later on)

like image 99
Ahmad Avatar answered Oct 06 '22 00:10

Ahmad