主要是在style文件中的设置
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="dialog_style" parent="Theme.AppCompat.Dialog">
<!--是否悬浮在activity上-->
<item name="android:windowIsFloating">true</item>
<!--透明是否-->
<item name="android:windowIsTranslucent">true</item>
<item name="android:background">#82858b</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowAnimationStyle">@style/animation_style</item>
</style>
<!--给dialog添加的动画效果,可选-->
<style name="animation_style" parent="Animation.AppCompat.Dialog">
<item name="android:windowEnterAnimation">@anim/window_inter</item>
<item name="android:windowExitAnimation">@anim/window_exist</item>
</style>
</resources>
并且在清单文件中引用
</activity>
<activity android:name=".DialogActivity"
android:theme="@style/dialog_style">
</activity>
效果如图