使用 XML 在 Android 中创建 3D 翻转动画 [英] Creating a 3D flip animation in Android using XML

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

问题描述

我使用 这个安卓教程但是,我已经以编程方式完成了它,如果可能的话,我想在 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) 创建一个名为animator"的新资源文件夹.

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

2) 创建一个新的 .xml 文件,我将其称为翻转".使用以下 xml 代码:

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) 使用以下代码启动动画:

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();

我从这里获得了所有这些.

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

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