gpt4 book ai didi

android - android中的摇晃/摆动 View 动画

转载 作者:IT老高 更新时间:2023-10-28 13:14:11 49 4
gpt4 key购买 nike

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

<?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 进行了非常合理的模仿。显然,您可以根据自己的喜好微调参数。

<?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 - android中的摇晃/摆动 View 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9448732/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com