Dialog弹出动画

点击按钮弹出对话框的动画效果

private void showPromptDlg() {
    new PromptDialog(this)
        .setDialogType(PromptDialog.DIALOG_TYPE_SUCCESS)
        .setAnimationEnable(true)
        .setTitleText(getString(R.string.success))
        .setContentText(getString(R.string.text_data))
        .setPositiveListener(getString(R.string.ok), new PromptDialog.OnPositiveListener() {
            @Override
public void onClick(PromptDialog dialog) {
                dialog.dismiss();
}
        }).show();
}

public void showTextDialog(View view) {
    ColorDialog dialog = new ColorDialog(this);
dialog.setColor("#8ECB54");
dialog.setAnimationEnable(true);
dialog.setTitle(getString(R.string.operation));
dialog.setContentText(getString(R.string.content_text));
dialog.setPositiveListener(getString(R.string.text_iknow), new ColorDialog.OnPositiveListener() {
        @Override
public void onClick(ColorDialog dialog) {
            Toast.makeText(MainActivity.this, dialog.getPositiveText().toString(), Toast.LENGTH_SHORT).show();
}
    }).show();
}

public void showPicDialog(View v) {
    ColorDialog dialog = new ColorDialog(this);
dialog.setTitle(getString(R.string.operation));
dialog.setAnimationEnable(true);
dialog.setAnimationIn(getInAnimationTest(this));
dialog.setAnimationOut(getOutAnimationTest(this));
dialog.setContentImage(getResources().getDrawable(R.mipmap.sample_img));
dialog.setPositiveListener(getString(R.string.delete), new ColorDialog.OnPositiveListener() {
        @Override
public void onClick(ColorDialog dialog) {
            Toast.makeText(MainActivity.this, dialog.getPositiveText().toString(), Toast.LENGTH_SHORT).show();
}
    })
    .setNegativeListener(getString(R.string.cancel), new ColorDialog.OnNegativeListener() {
        @Override
public void onClick(ColorDialog dialog) {
            Toast.makeText(MainActivity.this, dialog.getNegativeText().toString(), Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
    }).show();
}

public void showAllModeDialog(View view) {
    ColorDialog dialog = new ColorDialog(this);
dialog.setTitle(getString(R.string.operation));
dialog.setAnimationEnable(true);
dialog.setContentText(getString(R.string.content_text));
dialog.setContentImage(getResources().getDrawable(R.mipmap.sample_img));
dialog.setPositiveListener(getString(R.string.delete), new ColorDialog.OnPositiveListener() {
        @Override
public void onClick(ColorDialog dialog) {
            Toast.makeText(MainActivity.this, dialog.getPositiveText().toString(), Toast.LENGTH_SHORT).show();
}
    })
    .setNegativeListener(getString(R.string.cancel), new ColorDialog.OnNegativeListener() {
        @Override
public void onClick(ColorDialog dialog) {
            Toast.makeText(MainActivity.this, dialog.getNegativeText().toString(), Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
    }).show();
}

public static AnimationSet getInAnimationTest(Context context) {
    AnimationSet out = new AnimationSet(context, null);
AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
alpha.setDuration(150);
ScaleAnimation scale = new ScaleAnimation(0.6f, 1.0f, 0.6f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scale.setDuration(150);
out.addAnimation(alpha);
out.addAnimation(scale);
    return out;
}

public static AnimationSet getOutAnimationTest(Context context) {
    AnimationSet out = new AnimationSet(context, null);
AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
alpha.setDuration(150);
ScaleAnimation scale = new ScaleAnimation(1.0f, 0.6f, 1.0f, 0.6f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scale.setDuration(150);
out.addAnimation(alpha);
out.addAnimation(scale);
    return out;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值