1、自定义Dialog,构造器中使用Theme,如下:

觉得这种方式使用的挺优雅的,比较有意思。

1 public class PersonManageDialog extends Dialog {
2 
3     public PersonManageDialog(Context context) {
4         super(context, R.style.theme_manage_dialog);
5     }

theme_manage_dialog.xml

1 <style name="theme_manage_dialog" parent="@android:style/Theme.Dialog">
2         <item name="android:windowNoTitle">true</item>
3         <item name="android:backgroundDimEnabled">true</item>
4         <item name="android:backgroundDimAmount">0.6</item>
5         <item name="android:windowAnimationStyle">@style/manage_dialog_anim</item>
6         <item name="android:windowBackground">@android:color/transparent</item>
7     </style>

manage_dialog_anim.xml

1 <style name="manage_dialog_anim" parent="android:Animation">
2         <item name="android:windowEnterAnimation">@anim/push_up_in</item>
3         <item name="android:windowExitAnimation">@anim/push_up_out</item>
4     </style>

push_up_in.xml

1 <?xml version="1.0" encoding="utf-8"?>
2 <set xmlns:android="http://schemas.android.com/apk/res/android"
3     android:duration="300">
4     <translate
5         android:fromYDelta="100%p"
6         android:toXDelta="0" />
7 </set>

push_up_out.xml

1 <?xml version="1.0" encoding="utf-8"?>
2 <set xmlns:android="http://schemas.android.com/apk/res/android"
3     android:duration="500">
4     <translate
5         android:fromYDelta="0"
6         android:toYDelta="100%p" />
7 </set>

 

 posted on 2017-08-28 18:01  wlrhnh  阅读(181)  评论(0编辑  收藏  举报