Enable animateLayoutChanges for list view only for >ICS
We are going to dynamically enable animateLayoutChanges only for
JB and later (SDK 16 and above). This is because for pre-SDK-16, often you
can see the gradual fade-in and fade-out effects of the list view which
is not desirable.
b/14302062
Change-Id: I5f647d60fd4e6d3153c84e015dc1941d36b49a02
diff --git a/res/layout/conversation_list.xml b/res/layout/conversation_list.xml
index 4d87975..2d2bfa8 100644
--- a/res/layout/conversation_list.xml
+++ b/res/layout/conversation_list.xml
@@ -29,9 +29,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
+ android:id="@+id/conversation_list_parent_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:animateLayoutChanges="true"
android:clickable="true">
<!-- Note: intentionally not called "empty" because we call
setEmptyView programmatically-->
diff --git a/res/layout/conversation_list_empty_view.xml b/res/layout/conversation_list_empty_view.xml
index 93e905a..c5dc31c 100644
--- a/res/layout/conversation_list_empty_view.xml
+++ b/res/layout/conversation_list_empty_view.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
- android:visibility="gone" >
+ android:visibility="invisible" >
<ImageView
android:id="@+id/empty_icon"
diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java
index b2b4e1c..7d6b812 100644
--- a/src/com/android/mail/ui/ConversationListFragment.java
+++ b/src/com/android/mail/ui/ConversationListFragment.java
@@ -17,6 +17,7 @@
package com.android.mail.ui;
+import android.animation.LayoutTransition;
import android.app.Activity;
import android.app.ListFragment;
import android.app.LoaderManager;
@@ -495,6 +496,12 @@
mListView.setListItemSwipedListener(this);
mListView.setSwipeListener(this);
+ // enable animateOnLayout (equivalent of setLayoutTransition) only for >=JB (b/14302062)
+ if (Utils.isRunningJellybeanOrLater()) {
+ ((ViewGroup) rootView.findViewById(R.id.conversation_list_parent_frame))
+ .setLayoutTransition(new LayoutTransition());
+ }
+
// By default let's show the list view
showListView();