Layout weight different behavior in Android 4 and Android 5

I do have an Android application and it’s been working perfectly fine in Androids 2.3 – 4.4
Recently I wanted to update the application but I’ve noticed that in Android 5 my layouts are not laying out properly (or in other words are not laying out the same as they were in the previous versions).

I don’t do Android Development on a daily basis so I am not up to date with all the changes, but did Android 5 change anything with the way Layout Weight work?

For the records, my xml:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <ListView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:id="@+id/list_view"
        android:layout_weight="1"
        android:divider="@color/white"
        android:dividerHeight="2dp" />

    <LinearLayout
        android:id="@+id/places_holder"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:gravity="center"
        android:paddingTop="5dp"
        android:paddingBottom="5dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/iv_prev"
            android:src="@drawable/prev"
            android:layout_marginRight="10dp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/iv_party"
            android:src="@drawable/party"
            android:layout_marginRight="10dp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/iv_map "
            android:src="@drawable/map"
            android:layout_marginRight="10dp" />

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/imageView"
                android:src="@drawable/pin" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="+1"
                android:id="@+id/textView"
                android:textSize="11sp"
                android:background="@drawable/badgeshape"
                android:gravity="center_vertical|center_horizontal"
                android:textColor="@color/white"
                android:visibility="visible"
                android:layout_centerVertical="true"
                android:layout_centerHorizontal="true" />
        </RelativeLayout>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/iv_next"
            android:src="@drawable/next" />


    </LinearLayout>

</LinearLayout>


Source: xml

Leave a Reply