先添加一个动画文件(res->anim文件夹中),文件名为a.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <scale xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="3000"
        android:fromXScale="0.0"
        android:fromYScale="0.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="1.0"
        android:toYScale="1.0">
    </scale>

</set>

接着在style.xml文件中加上:

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
//对话框动画
<style name="dialog_animation" parent="@android:style/Animation.Dialog">
    <item name="android:windowEnterAnimation">@anim/a</item>
    <!--<item name="android:windowExitAnimation">@anim/a</item>-->
</style>

最后在java代码中调用:

Window window = dialog.getWindow();
window.setWindowAnimations(R.style.dialog_animation);

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄