我想滑入和滑出按钮单击事件上的活动。如何在单击按钮时滑动和滑出活动。
1
A
回答
0
您可以使用android.widget.ViewFlipper:http://developer.android.com/reference/android/widget/ViewFlipper.html
简单的例子: http://r00tsecurity.org/forums/topic/12057-android-viewflipper-example/
希望它可以帮助
0
试试这个,
随着viewflipper u能做到这一点。
private Animation inFromTopAnimation() {
Animation inFromTop = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromTop.setDuration(1000);
inFromTop.setInterpolator(new AccelerateInterpolator());
return inFromTop;
}
private Animation outToBottomAnimation() {
Animation outtoBottom = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, +1.0f
);
outtoBottom.setDuration(1000);
outtoBottom.setInterpolator(new AccelerateInterpolator());
return outtoBottom;
}
private Animation outToTopAnimation() {
Animation inFromTop = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromTop.setDuration(1000);
inFromTop.setInterpolator(new AccelerateInterpolator());
return inFromTop;
}
private Animation outFromBottomAnimation() {
Animation outFromBottom = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f
);
outFromBottom.setDuration(1000);
outFromBottom.setInterpolator(new AccelerateInterpolator());
return outFromBottom;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flipper = (ViewFlipper) findViewById(R.id.flipper);
ImageView imgview1 = (ImageView) findViewById(R.id.imageview1);
Button button2 = (Button) findViewById(R.id.flipback);
imgview1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromTopAnimation());
flipper.setOutAnimation(outToBottomAnimation());
flipper.showNext();
}
});
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(outToTopAnimation());
flipper.setOutAnimation(outFromBottomAnimation());
flipper.showPrevious();
}
});
6
从2.1个词你会做到这一点。首先,您将从api演示下载anim文件夹。然后像下面一样申请每个意图。
Intent intent = new Intent(Fisrst.this, Second.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
0
以下代码为我工作: A - > B(B将在滑入)
在活性B:
protected void onCreate(Bundle savedInstanceState) {
//do something...
view.startAnimation(AnimationUtils.loadAnimation(this, R.anim.g_slide_in_right));
}
乙 - > A(B会滑出) 点击了某个按钮B:
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent myIntent = new Intent(B.this.getBaseContext(), A.class);
B.this.startActivity(myIntent);
}
}, 500);
相关问题
- 1. 按钮和滑动菜单
- 2. React native在按钮上单击滑动
- 3. 如何在标签栏按钮单击角度时滑动?
- 4. 我如何动画我的div滑出按钮单击
- 5. 如何处理滑动门和非活动按钮
- 6. 在单击事件(滑动滑块)上滑动滑块
- 7. HTML单选按钮折叠和滑动
- 8. 如何在首页按钮上滑动打开滑动抽屉
- 9. 滑块菜单错误和活动按钮
- 10. 如何点击按钮时滑动RecyclerView项目?
- 11. 单击按钮上的动画滑动div jQuery
- 12. JQuery - 检查滑动滑动时滑动
- 13. 单击按钮和侧面菜单从隐藏中滑出
- 14. 如何在按钮上滑动Div点击
- 15. 如何在Android中滑动活动
- 16. 如何实现WatchKit滑动按钮?
- 17. Css按钮滑动门
- 18. 在活动之间滑动
- 19. 滑动按活动运行Do OnBackPress
- 20. 滑动时滑动删除
- 21. 滑动门CSS,按钮标记和IE8
- 22. 滑动div和切换按钮
- 23. 动画jQuery和css滑块按钮
- 24. jQuery的UI滑块值取决于活动的单选按钮
- 25. jquery点击功能滑动滑动
- 26. 如何删除滑动滑块默认滑动时间?
- 27. 滑动并单击一个按钮量角器
- 28. 单击后退按钮时活动组不会刷新活动
- 29. 自动滑动水平滑块滑动点击以及
- 30. javascript,将按钮单击下滑div div?
Thanx harish ... –