android 实现由下至上弹出并位于屏幕底部的提示框【转】
16lz
2021-01-23
[java] view plain copy
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- // TODO Auto-generated method stub
- AlertDialog dialog = new AlertDialog.Builder(TestAndroid1Activity.this)
- .setTitle("title").setMessage("message").create();
- Window window = dialog.getWindow();
- window.setGravity(Gravity.BOTTOM); //此处可以设置dialog显示的位置
- window.setWindowAnimations(R.style.mystyle); //添加动画
- dialog.show();
- }
- );
styles.xml
[java] view plain copy- <?xml version="1.0" encoding="utf-8"?>
-
位于 res/anim/dialog_enter.xml
- <?xml version="1.0" encoding="utf-8"?>
-
"http://schemas.android.com/apk/res/android" > -
- android:fromYDelta="100%p" %p指相对于父容器
- android:duration="600"
- />
位于 res/anim/dialog_exit.xml
- <?xml version="1.0" encoding="utf-8"?>
-
"http://schemas.android.com/apk/res/android" > -
- android:toYDelta="100%p"
- android:duration="600" //持续时间
- />
此处只是做了垂直位移的效果,自己还可以试试别的效果。
透明度
来自:http://blog.csdn.net/centralperk/article/details/7494441
更多相关文章
- Android UI - GridView长按实现拖拽效果
- android 拖动图片移动效果
- android实现播放器反射性动画效果
- Android显示GIF动画完整示例(一)
- 分享一个Android左右侧滑的效果实现 sliding layout
- android 关于再按一次退出程序效果
- Android实现CoverFlow效果三