我试图从它的位置到屏幕边缘对 View 进行动画处理,100%p
将 View 移出屏幕,
图像描述了所需的动画,对于任何要求代码的人:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fillAfter="true" >
<translate
android:fromXDelta="0%"
android:toXDelta="100%" />
</set>
任何帮助将不胜感激
最佳答案
来自 android doc :
android:toXDelta
Float or percentage. Ending X offset. Expressed either: in pixels relative to the normal position (such as "5"), in percentage relative to the element width (such as "5%"), or in percentage relative to the parent width (such as "5%p").
假设您的按钮宽度是其父级宽度的 20%,您必须将 toXDelta 指定为
50%p-(20%p/2) = 40%p
此解决方案的问题是您可能不知道按钮宽度的“父级宽度的百分比”(不确定,因为您没有发布 xml)。所以我建议以编程方式定义动画。
关于android - 将 View 动画转换到屏幕边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14090700/