我有一个活动(比如说homeActivity),当我从家庭活动开始一个新活动(比如说nextActivity)时,我想给它一个动画效果,就像从底部出现它一样。在android中可能吗?android中的动画
6
A
回答
2
您可以在意图中使用Intent.FLAG_ACTIVITY_NO_ANIMATION标志防止默认动画(从右侧滑入)。
即:
Intent myIntent = new Intent(context, MyActivity.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
context.startActivity(myIntent);
然后在你的活动,你只需指定自己的动画。
6
在致电startActivity
后,致电overridePendingTransition
用xml的id定义动画,一个用于退出活动,一个用于输入。请参阅此方法的文档here
1
TopListActivity topList;
Vector<BitmapDrawable> images;
int count = 0;
public AnimationAlphaTimer(TopListActivity _topList)
{
this.topList = _topList;
this.images = new Vector<BitmapDrawable>();
for (int i = 0; ; i++) {
// LOAD IMAGES HERE
}
if (this.images.size() > 0) {
this.topList.slide_0.setBackgroundDrawable(this.images.get(0));
if (this.images.size() > 1) {
this.topList.slide_1.setBackgroundDrawable(this.images.get(1));
}
}
this.count = 1;
}
public void launch()
{
if (this.images.size() >= 2) {
(new Timer(false)).schedule(this, 100);
}
}
@Override
public void run()
{
this.doit();
this.cancel();
}
private void doit()
{
if ((this.count % 2) == 0) {
AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
animation.setStartOffset(3000);
animation.setDuration(3000);
animation.setFillAfter(true);
animation.setAnimationListener(this);
this.topList.slide_1.startAnimation(animation);
} else {
AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setStartOffset(3000);
animation.setDuration(3000);
animation.setFillAfter(true);
animation.setAnimationListener(this);
this.topList.slide_1.startAnimation(animation);
}
}
public void onAnimationEnd(Animation animation)
{
if ((this.count % 2) == 0) {
this.topList.slide_1.setBackgroundDrawable(
this.images.get((this.count + 1) % (this.images.size()))
);
} else {
this.topList.slide_0.setBackgroundDrawable(
this.images.get((this.count + 1) % (this.images.size()))
);
}
this.count++;
this.doit();
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}}
试试这个我认为它会工作。
相关问题
- 1. Android中的动画
- 2. Android中的动画
- 3. Android中的动画
- 4. 动画中的Android
- 5. android中的动画?
- 6. Android中的动画
- 7. Android中的滑动动画
- 8. 动画动画中一个playTogether动画集Android中的动画集合
- 9. Tween动画和Android中的帧动画动画
- 10. 的Android动画
- 11. 动画的android
- 12. Android的动画 -
- 13. Android动画动画列表动画
- 14. Android中的动画查询
- 15. .gif动画中的Android
- 16. Android动画中的java.util.ConcurrentModificationException
- 17. 3D动画中的Android
- 18. Android中的AppWidget动画
- 19. Android中的动画细节
- 20. android中的3d动画
- 21. Android Wear:WatchFace中的动画
- 22. android中的图像动画
- 23. Android中的动画gif
- 24. Html5中的Android Flipbook动画
- 25. Android中的对象动画
- 26. 在android中的帧动画
- 27. WindowManager中的动画ImageView - Android
- 28. android中的按钮动画
- 29. Android中的框架动画?
- 30. Android WebView中的动画