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是视图的宽度。

相关内容

热门资讯

第八分钟窍要!德普之星有辅助软... 第八分钟窍要!德普之星有辅助软件吗(透视)切实有辅助透视(哔哩哔哩)该软件可以轻松地帮助玩家将德普之...
第4分钟手册!wepoker好... 第4分钟手册!wepoker好友房开挂(透视)竟然是有辅助安装(哔哩哔哩)wepoker好友房开挂能...
2分钟指南书!wepoker养... 2分钟指南书!wepoker养号规律(透视)真是有辅助透视(哔哩哔哩)wepoker养号规律辅助器是...
九分钟方针!wepoker俱乐... 九分钟方针!wepoker俱乐部辅助(透视)好像真的有辅助脚本(哔哩哔哩)1、起透看视 wepoke...
8分钟妙招!德州局脚本(透视)... 8分钟妙招!德州局脚本(透视)都是是真的有辅助安装(哔哩哔哩)德州局脚本辅助器是一种具有地方特色的麻...
两分钟大纲!hhpoker脚本... 两分钟大纲!hhpoker脚本下载(透视)一直真的是有辅助开挂(哔哩哔哩)1、hhpoker脚本下载...
第三分钟总结!wepoker透... 第三分钟总结!wepoker透视脚本免费下载pc(透视)竟然是有辅助安装(哔哩哔哩)1、wepoke...
8分钟操作!hhpoker怎么... 8分钟操作!hhpoker怎么防作必弊(透视)其实有辅助脚本(哔哩哔哩)1、全新机制【hhpoker...
八分钟指南书!wepoker安... 八分钟指南书!wepoker安装教程(透视)总是是真的有辅助透视(哔哩哔哩)一、wepoker安装教...
第六分钟教程书!wepoker... 第六分钟教程书!wepoker能不能透视(透视)切实存在有辅助透视(哔哩哔哩)暗藏猫腻,小编详细说明...