创建一个3D翻转动画中使用XML的Andr​​oid创建一个、画中、XML、Andr

2023-09-07 22:20:15 作者:心已拿走还肿么爱o

我创建了一个视图使用3D翻转这个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();

我得到了这一切从这里。