Last active
August 29, 2015 14:18
-
-
Save happycodinggirl/c466160867007f83f5f2 to your computer and use it in GitHub Desktop.
ViewAnimator笔记
This file contains hidden or 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" | |
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | |
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> | |
<ViewAnimator | |
android:layout_width="60dp" | |
android:layout_height="60dp" | |
android:id="@+id/viewanimator"> | |
<View | |
android:background="@drawable/rect" | |
android:id="@+id/view1" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content"/> | |
<View | |
android:id="@+id/view2" | |
android:background="@drawable/oval" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
/> | |
</ViewAnimator> | |
</RelativeLayout> |
This file contains hidden or 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 com.lily.huangxingli.testviewanimator; | |
import android.animation.Animator; | |
import android.support.v7.app.ActionBarActivity; | |
import android.os.Bundle; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import android.widget.ViewAnimator; | |
public class MainActivity extends ActionBarActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
final ViewAnimator viewAnimator= (ViewAnimator) findViewById(R.id.viewanimator); | |
viewAnimator.setDisplayedChild(1); | |
viewAnimator.animate().setDuration(3000) | |
.translationZ(20).setListener(new Animator.AnimatorListener() { | |
@Override | |
public void onAnimationStart(Animator animation) { | |
} | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
viewAnimator.showNext(); | |
} | |
@Override | |
public void onAnimationCancel(Animator animation) { | |
} | |
@Override | |
public void onAnimationRepeat(Animator animation) { | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment