1

I have always used separate layout folders to support features available in newer API versions. One of these features is layout transition using animateLayoutChanges. For this, I create folders layout and layout-v11 and their landscape counterparts.

Today, I found out that having animateLayoutChanges in xml does not raise a flag on API versions < 11. Why is this? Testing on API 8, layout animations were not present, but the app didn't crash either.

Does this mean that I don't have to create separate layout folders (and separate xml files) to support this feature?

To make things clear, here's an example of what I am doing:

res/layout/activity.xml:

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

    <TextView
        android:id="@+id/tvMessage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Example"
        android:textColor="@color/some_color"
        android:textSize="@dimen/text_size_message" />

    ....
    ....

</LinearLayout>

res/layout-v11/activity.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/llMainContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:animateLayoutChanges="true" >  <<<<<<<<<<<<====================

    <TextView
        android:id="@+id/tvMessage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Example"
        android:textColor="@color/some_color"
        android:textSize="@dimen/text_size_message" />

    ....
    ....

</LinearLayout>
user3264740
  • 231
  • 1
  • 2
  • 13
  • I believe unknown xml properties are ignored at run time. Which makes sense- it allows forward compatibility. They are flagged at compile time because it likely means something you expected won't work right. – Gabe Sechan Mar 16 '14 at 06:18
  • @GabeSechan Okay, that does make sense. Would have been cleaner if it was one way or another. At times, I find myself creating duplicate files with just one code-line of difference. Thanks. Is this confirmed somewhere on developer.android.com? – user3264740 Mar 16 '14 at 06:25

0 Answers0