AndroidViewanimationshowslideleftandhideslideright
创始人
2024-08-22 00:30:11
0

在Android中,将视图动画显示为向左滑动,并向右隐藏,可以使用TranslateAnimation类。 将视图向左移动,可以设置fromXDelta为0,toXDelta为负值。同样,将视图向右移动,可以将fromXDelta设置为负值,而toXDelta设置为0。以下是一个简单示例:

//将视图向左移动 Animation slideLeft = new TranslateAnimation(0, -viewWidth, 0, 0); slideLeft.setDuration(500); slideLeft.setFillAfter(true); view.startAnimation(slideLeft);

//将视图向右移动 Animation slideRight = new TranslateAnimation(-viewWidth, 0, 0, 0); slideRight.setDuration(500); slideRight.setFillAfter(true); view.startAnimation(slideRight);

在这里,viewWidth表示视图的宽度。还可以使用属性动画来实现这个效果。使视图向左滑动的示例代码如下:

ObjectAnimator anim = ObjectAnimator.ofFloat(view, "translationX", 0, -viewWidth); anim.setDuration(500); anim.start();

同样,向右滑动的属性动画示例代码如下:

ObjectAnimator anim = ObjectAnimator.ofFloat(view, "translationX", -viewWidth, 0); anim.setDuration(500); anim.start();

这里的viewWidth是视图的宽度。

相关内容

热门资讯

hhpoker一直输有挂吗!h... hhpoker一直输有挂吗!hhpoker德州透视挂(透视)挂-果然普及存在有挂1、下载好hhpok...
透视有挂!德普之星私人局透视(... 透视有挂!德普之星私人局透视(透视)wejoker开挂,教程攻略(有挂技术)-哔哩哔哩1、每一步都需...
wepoker私人局规律!德州... wepoker私人局规律!德州私人局脚本(透视)脚本-真是了解是真的挂1、在wepoker私人局规律...
透视揭幕!wepoker私人局... 透视揭幕!wepoker私人局透视插件(透视)红龙poker辅助工具,教程积累(有挂规律)-哔哩哔哩...
透视分享!hhpoker透视方... 透视分享!hhpoker透视方法(透视)werplan免费挂下载,教程指引(有挂教学)-哔哩哔哩一、...
poker辅助器免费安装!拱趴... poker辅助器免费安装!拱趴大菠萝十三水透视(透视)app-确实了解是真的挂暗藏猫腻,小编详细说明...
透视详情!wejoker透视方... 透视详情!wejoker透视方法(透视)hhpoker透视脚本下载,教程阶段(有挂细节)-哔哩哔哩1...
拱趴大菠萝有挂吗!hhpoke... 拱趴大菠萝有挂吗!hhpoker透视工具(透视)方法-果然必备真的有挂1、拱趴大菠萝有挂吗模拟器是什...
wepoker软件辅助程序!p... wepoker软件辅助程序!pokerworld软件(透视)工具-确实解谜是真的挂1、金币登录送、破...
透视解谜!wepoker免费辅... 透视解谜!wepoker免费辅助器(透视)aapoker怎么设置抽水,教程演示(真的有挂)-哔哩哔哩...