Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中弹出窗口的动画_Android_Animation_Android Intent_Popup_Android Animation - Fatal编程技术网

android中弹出窗口的动画

android中弹出窗口的动画,android,animation,android-intent,popup,android-animation,Android,Animation,Android Intent,Popup,Android Animation,20秒后,我在mainactivity中创建一个弹出窗口。我在UI的右上角有一个小的imageview。我希望我的弹出窗口来自该图像(如动画或从图像缩放闪光灯并显示弹出窗口)。我该怎么做?希望你明白我的意思。这是我在MainActivity类中完成的弹出代码 Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override publi

20秒后,我在mainactivity中创建一个弹出窗口。我在UI的右上角有一个小的imageview。我希望我的弹出窗口来自该图像(如动画或从图像缩放闪光灯并显示弹出窗口)。我该怎么做?希望你明白我的意思。这是我在MainActivity类中完成的弹出代码

Handler handler = new Handler();

        handler.postDelayed(new Runnable() {

            @Override

            public void run() {

                new AlertDialog.Builder(context)
                        .setTitle("Win Free Recharge")
                        .setMessage("Do you want to earn free recharge?")
                        .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // continue with delete
                                Intent intent = new Intent(MainActivity.this, WebActivity.class);
                                startActivity(intent);
                            }
                        })
                        .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // do nothing
                            }
                        })
                        .setIcon(R.drawable.inr1)
                        .show();
            }
        }, 20000);

在样式中添加此样式属性

<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="android:windowEnterAnimation">@anim/anim_scale_in</item>
        <item name="android:windowExitAnimation">@anim/anim_scale_out</item>
        <item name="colorAccent">@color/colorPrimary</item>
</style>
在动画文件夹中,创建
anim\u scale\u out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="@android:integer/config_shortAnimTime"
        android:interpolator="@android:interpolator/accelerate_decelerate"
        android:pivotX="50%"
        android:pivotY="50%"
        android:fromXScale="0.7"
        android:toXScale="1.0"
        android:fromYScale="0.7"
        android:toYScale="1.0"/>

    <alpha
        android:duration="@android:integer/config_shortAnimTime"
        android:interpolator="@android:interpolator/accelerate_decelerate"
        android:fromAlpha="0"
        android:toAlpha="1.0"/>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="@android:integer/config_shortAnimTime"
        android:interpolator="@android:interpolator/accelerate_decelerate"
        android:pivotX="50%"
        android:pivotY="50%"
        android:fromXScale="1.0"
        android:toXScale="0.7"
        android:fromYScale="1.0"
        android:toYScale="0.7"/>

    <alpha
        android:duration="@android:integer/config_shortAnimTime"
        android:interpolator="@android:interpolator/accelerate_decelerate"
        android:fromAlpha="1.0"
        android:toAlpha="0.0"/>

</set>

谢谢弹出对话框很好,但我的主要问题是如何从UI右上角的imageview中打开它。我想我的弹出窗口来作为闪光从该图像。在这里,过了一段时间,它突然出现了。请帮忙!!!
AlertDialog.Builder alert = new AlertDialog.Builder(mContext, R.style.MyAlertDialogStyle)
                        .setTitle("Title")
                        .setMessage("Message")
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        }).setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                dialogInterface.dismiss();
                            }
                        });
                Dialog mDialog = alert.create();
                mDialog.getWindow().getAttributes().windowAnimations = R.style.MyAlertDialogStyle;
                mDialog.show();