gpt4 book ai didi

android - 如何围绕 View 中心制作比例动画?

转载 作者:搜寻专家 更新时间:2023-11-01 09:05:24 24 4
gpt4 key购买 nike

我从 XML 文件加载一个比例动画,然后将其设置为查看并启动它。
我发现动画围绕着 View 的左上角。
我怎样才能让它围绕中心?

这是我的动画 XML

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="0.5"
android:toXScale="1.1"
android:fromYScale="0.5"
android:toYScale="1.1"
android:duration="200"/>
<scale
android:fromXScale="1"
android:toXScale="0.91"
android:fromYScale="1"
android:toYScale="0.91"
android:startOffset="200"
android:duration="400"/>
<alpha
android:fromAlpha="0.5"
android:toAlpha="1"
android:duration="400"/>
<alpha
android:fromAlpha="1"
android:toAlpha="0"
android:duration="300"
android:startOffset="700"/>

</set>

和java代码

rightAnim = AnimationUtils.loadAnimation(this, R.anim.show_fade_out);
rightAnimObj.setAnimation(rightAnim);
rightAnim.startNow();

最佳答案

为什么不使用 android:pivotX/android:pivotY ? http://developer.android.com/guide/topics/resources/animation-resource.html

唯一的事情 - 小心值,我认为你需要 50% 或 50%p 之类的值

祝你好运

关于android - 如何围绕 View 中心制作比例动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12236359/

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