[英]animate a slab out of view in android
我有一个用RelativeLayout制成的平板,其中高度为wrap_content(大约40dp
),宽度为match_parent。 我想为平板制作动画,使其随着从屏幕向右滑出而变得越来越小。 我有以下代码,但无法正常工作。
res / anim / slab_animation:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<scale android:fromXScale="1.0" android:fromYScale="1.0"
android:toXScale="0.0" android:toYScale="0.0"
android:duration="7000" android:fillBefore="false" />
<translate android:fromXDelta="-200" android:fromYDelta="-200"
android:duration="7000" />
</set>
在Java类中:
Animation slabAnim = AnimationUtils.loadAnimation(this, R.anim.slab_animation);
mySlabView.startAnimation(slabAnim);
我猜想您在translate
动画中缺少toXDelta
参数的参数,而您只想进行水平翻译。
<translate android:fromXDelta="-200"
android:toXDelta="400"
android:duration="7000" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.