gpt4 book ai didi

Android:在 View 区域外使用动画

转载 作者:搜寻专家 更新时间:2023-11-01 08:10:37 25 4
gpt4 key购买 nike

我有一个包含 12 个图像的 xml。例如 3*4 表,其中每个单元格包含一个图像。在 OnCreate 中,我为每个图像编写动画:

AnimationSet set = new AnimationSet(true);
Animation animation = new TranslateAnimation(
Animation.ABSOLUTE, -300.0f, Animation.START_ON_FIRST_FRAME, 0.0f,
Animation.ABSOLUTE, -800.0f, Animation.START_ON_FIRST_FRAME, 0.0f);

animation.setFillBefore(true);
animation.setFillAfter(true);
animation.setFillEnabled(true);
animation.setDuration(5000);

我想从屏幕的左上角开始动画,到真实位置结束动画。但动画仅使用图像或单元格区域。动画有什么解决办法,用全屏吗?

最佳答案

如果它们都在同一个父 View 下,您可以将父 View 的 clipChildren 属性设置为 false,这将允许动画扩展到其自身的约束之外(只要它仍然保持在其父 View 的边界内):

android:clipChildren="false"

关于Android:在 View 区域外使用动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9973916/

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