我正在创建类似SlideDrawer的东西,但是大多数自定义,基本上这个东西都在工作,但动画最后会闪烁.
为了进一步解释,我得到了一个TranslateAnimation然后在这个动画之后它返回到原始位置,如果我设置了setFillAfter,那么布局内的按钮就会停止工作.如果我听onAnimationEnd并将其他布局设置为View.GONE布局fickers.从它的判断来看,在动画结束时,视图会在调用View.GONE之前返回到原始位置.
任何建议都会很棒.谢谢
这是简单的xml android动画:
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:fromYDelta="0" android:toXDelta="-110"
android:toYDelta="-110" android:duration="1000" android:fillAfter="true" />
Run Code Online (Sandbox Code Playgroud)
我想将动画对象从屏幕中心移动到0,0位置.我是如何做它的(它应该适用于所有屏幕分辨率)
谢谢你们的帮助.但我已经通过其他方式动态修复了我的问题,没有xml.这是这个方法的完整代码:
public void replace(int xTo, int yTo, float xScale, float yScale) {
// create set of animations
replaceAnimation = new AnimationSet(false);
// animations should be applied on the finish line
replaceAnimation.setFillAfter(true);
// create scale animation
ScaleAnimation scale = new ScaleAnimation(1.0f, xScale, 1.0f, yScale);
scale.setDuration(1000);
// create translation animation
TranslateAnimation trans = new TranslateAnimation(0, 0,
TranslateAnimation.ABSOLUTE, xTo - getLeft(), 0, 0,
TranslateAnimation.ABSOLUTE, yTo - getTop());
trans.setDuration(1000);
// add …Run Code Online (Sandbox Code Playgroud) 可能重复:
Android:完成后动画位置重置
我正在使用RotateAnimation旋转ImageView.代码很简单:
this.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Animation ani = new RotateAnimation(
0, /* from degree*/
30, /* to degree */
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
ani.setDuration(1000);
imageView.startAnimation(ani);
}
});
Run Code Online (Sandbox Code Playgroud)
你可以看到我希望imageView旋转30度.
它可以工作,但是当完成旋转时,图像会在旋转之前返回到原始状态,相同的位置和程度.我想在最后的动画位置修复ImageView,即想要将图像倾斜30度.怎么解决?