Android-按钮滑动效果

rah*_*ame 2 java android android-layout android-fragments

我想对屏幕一侧的箭头产生滑动效果.当我点击箭头时,将显示一个带滑动效果的按钮.我不知道我怎么做到这一点.

我想我可以在这个上使用嵌入式片段,但我不知道要实现幻灯片效果.

在此输入图像描述

can*_*ova 6

以下是实现此目的的代码.我也写了评论.

TranslateAnimation anim = new TranslateAnimation(0, 150, 0, 0); //first 0 is start point, 150 is end point horizontal
anim.setDuration(1000); // 1000 ms = 1second
yourarrow.startAnimation(anim); // your imageview that you want to give the animation. call this when you want it to take effect
Run Code Online (Sandbox Code Playgroud)

如果你希望它在动画之后保持这样,那么把它:

anim.setFillAfter(true);
Run Code Online (Sandbox Code Playgroud)