android中的抖动/摆动视图动画 [英] shaking / wobble view animation in android

查看:56
本文介绍了android中的抖动/摆动视图动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个如下所示的 anim.xml 文件来像在 android 中晃动 IOS 图标那样晃动图像视图.但是,它没有为我提供相同的结果.有没有更好的主意?

I created an anim.xml file such as below to shake imageview like IOS icon shaking in android. However it does not provide me same result. Is there any better idea?

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"

    android:fromDegrees="-2"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:toDegrees="2" />

推荐答案

尝试设置 android:repeatMode="reverse".下面的动画对我的 Galaxy Nexus 进行了非常合理的模仿.显然,您可以根据自己的喜好微调参数.

Try setting android:repeatMode="reverse". Below animation gives a very reasonable immitation on my Galaxy Nexus. Obviously you can fine tune the parameters to your own liking.

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="100"
    android:fromDegrees="-5"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:repeatMode="reverse"
    android:toDegrees="5" />

这篇关于android中的抖动/摆动视图动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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