Android -- Dialog动画
window_in.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="500" android:fromXDelta="0" android:fromYDelta="1000" android:toXDelta="0" android:toYDelta="0" /> </set>
window_out.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="500" android:fromXDelta="0" android:fromYDelta="0" android:toXDelta="0" android:toYDelta="1000" /> </set>
将动画配置到style中
<style name="main_menu_animstyle"> <item name="android:windowEnterAnimation">@anim/settingswindow_in_anim</item> <item name="android:windowExitAnimation">@anim/settingswindow_out_anim</item> </style>
将动画应用于Dialog
Window window = dialog.getWindow(); //设置显示动画 window.setWindowAnimations(R.style.main_menu_animstyle); WindowManager.LayoutParams wl = window.getAttributes(); wl.x = 0; wl.y = getWindowManager().getDefaultDisplay().getHeight(); //设置显示位置 dialog.onWindowAttributesChanged(wl);//设置点击外围解散 dialog.setCanceledOnTouchOutside(true); dialog.show();
我是天王盖地虎的分割线
可以参考github:https://github.com/pinguo-yuyidong/Study_Demos/tree/master/BottomMenu
作者:我爱物联网
出处:http://yydcdut.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://yydcdut.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。