Created
June 15, 2012 01:11
-
-
Save wabzqem/2934018 to your computer and use it in GitHub Desktop.
ListView Animation bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.whatsbeef.animationtest; | |
import android.animation.Animator; | |
import android.animation.Animator.AnimatorListener; | |
import android.animation.AnimatorInflater; | |
import android.animation.AnimatorSet; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.ArrayAdapter; | |
import android.widget.ListView; | |
public class AnimationTestActivity extends Activity { | |
private ListView indexList; | |
private String[] items = { | |
"Caused", | |
"By:", | |
"java.lang.NullPointerException", | |
"at", | |
"wat" | |
}; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
indexList = (ListView)findViewById(R.id.index_list); | |
indexList.setAdapter(new ArrayAdapter<String>(this, android.R.layout. simple_list_item_activated_1, items)); | |
} | |
public void onAnimateClick(View v) | |
{ | |
AnimatorSet anim; | |
if (indexList.getVisibility() == View.GONE) { | |
indexList.setVisibility(View.VISIBLE); | |
anim = (AnimatorSet) AnimatorInflater.loadAnimator(this, | |
R.anim.push_left_in); | |
anim.setTarget(indexList); | |
anim.start(); | |
} else { | |
//indexList.setVisibility(View.VISIBLE); | |
anim = (AnimatorSet) AnimatorInflater.loadAnimator(this, | |
R.anim.push_left_out); | |
anim.setTarget(indexList); | |
anim.addListener(new AnimatorListener() { | |
@Override | |
public void onAnimationCancel(Animator animation) { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
indexList.setVisibility(View.GONE); | |
} | |
@Override | |
public void onAnimationRepeat(Animator animation) { | |
} | |
@Override | |
public void onAnimationStart(Animator animation) { | |
} | |
}); | |
anim.start(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/animation_layout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<VideoView | |
android:id="@+id/imageView1" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:layout_alignParentLeft="true" | |
android:src="@drawable/ic_launcher" /> | |
<ListView | |
android:id="@+id/index_list" | |
android:layout_width="200dp" | |
android:layout_height="match_parent" | |
android:background="#aaffffff" | |
android:visibility="gone" > | |
</ListView> | |
<Button | |
android:id="@+id/button1" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentRight="true" | |
android:layout_alignParentTop="true" | |
android:onClick="onAnimateClick" | |
android:text="Button" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<set xmlns:android="http://schemas.android.com/apk/res/android" > | |
<objectAnimator | |
android:duration="300" | |
android:propertyName="x" | |
android:repeatCount="0" | |
android:startOffset="0" | |
android:valueFrom="-100" | |
android:valueTo="0" | |
android:valueType="floatType" /> | |
<objectAnimator | |
android:duration="300" | |
android:propertyName="rotationY" | |
android:repeatCount="0" | |
android:startOffset="0" | |
android:valueFrom="90" | |
android:valueTo="0" | |
android:valueType="floatType" /> | |
<objectAnimator | |
android:duration="300" | |
android:propertyName="alpha" | |
android:repeatCount="0" | |
android:startOffset="0" | |
android:valueFrom="0" | |
android:valueTo="1" | |
android:valueType="floatType" /> | |
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<set xmlns:android="http://schemas.android.com/apk/res/android" > | |
<objectAnimator | |
android:duration="300" | |
android:propertyName="x" | |
android:repeatCount="0" | |
android:startOffset="0" | |
android:valueFrom="0" | |
android:valueTo="-100" | |
android:valueType="floatType" /> | |
<objectAnimator | |
android:duration="300" | |
android:propertyName="rotationY" | |
android:repeatCount="0" | |
android:startOffset="0" | |
android:valueFrom="0" | |
android:valueTo="90" | |
android:valueType="floatType" /> | |
<objectAnimator | |
android:duration="300" | |
android:propertyName="alpha" | |
android:repeatCount="0" | |
android:startOffset="0" | |
android:valueFrom="1" | |
android:valueTo="0" | |
android:valueType="floatType" /> | |
</set> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment