创建一个3D翻转动画中使用XML的Andr​​oid [英] Creating a 3D flip animation in Android using XML

查看:101
本文介绍了创建一个3D翻转动画中使用XML的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个视图使用3D翻转<一href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.html"相对=nofollow>这个Android教程 不过,我已经做到了编程,我愿做这一切在XML中,如果可能的话。我说的不是简单地缩小,以便在中间,然后回了,但实际的3D翻转。

I have created a 3D flip of a view using this android tutorial However, I have done it programmatically and I would like to do it all in xml, if possible. I am not talking about simply shrinking a view to the middle and then back out, but an actual 3D flip.

通过XML是这可能吗?

Is this possible via xml?

推荐答案

下面是答案,但它仅适用于3.0及以上。

Here is the answer, though it only works with 3.0 and above.

1)创建一个名为动画师。

1) Create a new resources folder called "animator".

2)创建一个新的.xml文件,我会打电话给翻转。使用下面的XML code:

2) Create a new .xml file which I will call "flipping". Use the following xml code:

<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
    android:valueFrom="0" android:valueTo="360" android:propertyName="rotationY" >
</objectAnimator>

没有,在objectAnimator标签不以大写字母O。

No, the objectAnimator tags do not start with an uppercase "O".

3)具有以下code。启动动画:

3) Start the animation with the following code:

ObjectAnimator anim = (ObjectAnimator) AnimatorInflater.loadAnimator(mContext, R.animator.flipping); 
anim.setTarget(A View Object reference goes here i.e. ImageView);
anim.setDuration(3000);
anim.start();

我得到了这一切从这里

这篇关于创建一个3D翻转动画中使用XML的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆