Sam
Sam

Reputation: 87

Why is my ListView not getting animated?

Guys I made a customised list view, The list view has three text fields. I want t the following thing to work, when the user presses the back button from the activity he just filled the text views, he goes back to the activity containing the customised list view. The recent entry just made is already present there. I want the entry to swipe in from the right each time the user goes to the list view activity.here's the code for the list view xml:


    <LinearLayout
    android:id="@+id/listHolder"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="#ffffff" >

    <ListView
        android:id="@+id/mylist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </ListView>
    </LinearLayout>

here the list view is actually not utilising the complete space as 100dp of screen size is taken by some other widget(But that is not important here). And the animation I am using is this:


    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <scale
    android:duration="1500"
    android:fillAfter="false"
    android:fromXScale="480dp"
    android:fromYScale="0dp"
    android:interpolator="@android:anim/overshoot_interpolator"
    android:pivotX="60"
    android:pivotY="10"
    android:toXScale="100dp"
    android:toYScale="0dp" />

    </set>

What is wrong in the aniamtion xml? Have I set the parameters wrong for the x and y values? What I am getting is that the list view comes after a second or later the user goes to that activity. I mean there is no transition from right to left. Any idea why this is happening. Thanks.

Upvotes: 0

Views: 166

Answers (1)

Kailash Dabhi
Kailash Dabhi

Reputation: 3513

u havent even applied ur animation to listview then how can u show animation!] and u should put % in pivotY and pivotX use this code:

save this as layout_controller.xml in anim folder.

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
 android:animation="@anim/rotation"
 android:animationOrder="normal"
 android:delay="10%" />

save this as rotation.xml in anim folder

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromDegrees="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />

now put this code in yout listView layout file:

<LinearLayout
android:id="@+id/listHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#ffffff" >

<ListView
    android:id="@+id/mylist"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layoutAnimation="@anim/list_layout_controller" >
</ListView>
</LinearLayout>

i mean i have added this line in your layout now u can see it works..

android:layoutAnimation="@anim/list_layout_controller" 

Upvotes: 1

Related Questions