gpt4 book ai didi

android - 如何将 buttonView 从其原始位置移动到 Android 中的新位置?

转载 作者:太空狗 更新时间:2023-10-29 16:36:17 27 4
gpt4 key购买 nike

我在 (0,0) 位置有一个按钮,当我点击它时,它应该移动到 (-x,-y) 位置,例如 (-0,-2) 位置或 (x,-y) 位置for ex (0,-2) position.How to implement this logic.

最佳答案

你可以为此使用翻译动画

 Animation animation= AnimationUtils.loadAnimation( this, R.anim.animation);
button.startAnimation( animation);

res中创建amin文件夹并在 amin 文件夹中创建名为 animation.xml 的 xml

<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="-60"
android:toYDelta="-30" />
</set>

现在你可以玩翻译了

关于android - 如何将 buttonView 从其原始位置移动到 Android 中的新位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28061899/

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