一个Android对话框的库内置自带一些Dialog和显示消失动画提供直接使用. 也支持自定义无论是Dialog还是动画.

FlycoDialog-Matser

github link

This is an Android Dialog Library that you can directly use default inner dialog and default animation.
It has 6 kinds of diaog and many kings of show and dimiss animations inside Library.
It has good expansibility.If you don not like inner dialog and animation, you can custom them what you like in a sample way.

Demo

preview_FlycoDialog.gif

[Here is a DemoApk download]

(https://github.com/H07000223/FlycoDialog_Master/blob/master/FlycoDialogSamples.apk)

Gradle

dependencies{
    compile 'com.flyco.dialog:FlycoDialog_Lib:1.0.0'
}

Eclispe

Eclipse Developers should include jars blew into your porject.

Thanks

Usage

Inner Default Dialog(默认内置自带Dialog)

Here's the dialog usages corresponding to the demo listview item sort.(下面dialog使用方法和Demo中的列表顺序对应)


    BaseAnimatorSet bas_in = new FlipVerticalSwingEnter();
    BaseAnimatorSet bas_out = new FadeExit();
    private void NormalDialogStyleOne() {
            final NormalDialog dialog = new NormalDialog(context);
            dialog.content("是否确定退出程序?")//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnLeftClickL(new OnBtnLeftClickL() {
                @Override
                public void onBtnLeftClick() {
                    T.showShort(context, "onBtnLeftClick");
                    dialog.dismiss();
                }
            });

            dialog.setOnBtnRightClickL(new OnBtnRightClickL() {
                @Override
                public void onBtnRightClick() {
                    T.showShort(context, "onBtnRightClick");
                    dialog.dismiss();
                }
            });
        }

        private void NormalDialogStyleTwo() {
            final NormalDialog dialog = new NormalDialog(context);
            dialog.content("为保证咖啡豆的新鲜度和咖啡的香味,并配以特有的传统烘焙和手工冲。")//
                    .style(NormalDialog.STYLE_TWO)//
                    .titleTextSize(23)//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnLeftClickL(new OnBtnLeftClickL() {
                @Override
                public void onBtnLeftClick() {
                    T.showShort(context, "onBtnLeftClick定");
                    dialog.dismiss();
                }
            });

            dialog.setOnBtnRightClickL(new OnBtnRightClickL() {
                @Override
                public void onBtnRightClick() {
                    T.showShort(context, "onBtnRightClick");
                    dialog.dismiss();
                }
            });
        }

        private void NormalDialogCustomAttr() {
            final NormalDialog dialog = new NormalDialog(context);
            dialog.isTitleShow(false)//
                    .bgColor(Color.parseColor("#383838"))//
                    .cornerRadius(5)//
                    .content("是否确定退出程序?")//
                    .contentGravity(Gravity.CENTER)//
                    .contentTextColor(Color.parseColor("#ffffff"))//
                    .dividerColor(Color.parseColor("#222222"))//
                    .btnTextSize(15.5f, 15.5f)//
                    .btnTextColor(Color.parseColor("#ffffff"), Color.parseColor("#ffffff"))//
                    .btnColorPress(Color.parseColor("#2B2B2B"))//
                    .widthScale(0.85f)//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnLeftClickL(new OnBtnLeftClickL() {
                @Override
                public void onBtnLeftClick() {
                    T.showShort(context, "onBtnLeftClick");
                    dialog.dismiss();
                }
            });

            dialog.setOnBtnRightClickL(new OnBtnRightClickL() {
                @Override
                public void onBtnRightClick() {
                    T.showShort(context, "onBtnRightClick");
                    dialog.dismiss();
                }
            });
        }

        private void NormalTipDialogStyleOne() {
            final NormalTipDialog dialog = new NormalTipDialog(context);
            dialog.content("你今天的抢购名额已用完~")//
                    .btnText("继续逛逛")//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnClickL(new OnBtnClickL() {
                @Override
                public void onBtnClick() {
                    dialog.dismiss();
                }
            });
        }

        private void NormalTipDialogStyleTwo() {
            final NormalTipDialog dialog = new NormalTipDialog(context);
            dialog.content("你今天的抢购名额已用完~")//
                    .style(NormalTipDialog.STYLE_TWO)//
                    .btnText("继续逛逛")//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnClickL(new OnBtnClickL() {
                @Override
                public void onBtnClick() {
                    dialog.dismiss();
                }
            });
        }

        private void MaterialDialog() {
            final MaterialDialog dialog = new MaterialDialog(context);
            dialog.content(
                    "嗨!这是一个 MaterialDialog. 它非常方便使用,你只需将它实例化,这个美观的对话框便会自动地显示出来。"
                            + "它简洁小巧,完全遵照 Google 2014 年发布的 Material Design 风格,希望你能喜欢它!^ ^")//
                    .btnText("取消", "确定")//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnLeftClickL(new OnBtnLeftClickL() {
                @Override
                public void onBtnLeftClick() {
                    T.showShort(context, "onBtnLeftClick");
                    dialog.dismiss();
                }
            });

            dialog.setOnBtnRightClickL(new OnBtnRightClickL() {
                @Override
                public void onBtnRightClick() {
                    T.showShort(context, "onBtnRightClick");
                    dialog.dismiss();
                }
            });
        }


        private void MaterialDialogNoTitle() {
            final MaterialDialog dialog = new MaterialDialog(context);
            dialog.isTitleShow(false)//
                    .content("为保证咖啡豆的新鲜度和咖啡的香味,并配以特有的传统烘焙和手工冲。")//
                    .btnText("确定", "取消")//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnLeftClickL(new OnBtnLeftClickL() {
                @Override
                public void onBtnLeftClick() {
                    T.showShort(context, "onBtnLeftClick");
                    dialog.dismiss();
                }
            });

            dialog.setOnBtnRightClickL(new OnBtnRightClickL() {
                @Override
                public void onBtnRightClick() {
                    T.showShort(context, "onBtnRightClick");
                    dialog.dismiss();
                }
            });
        }

        private void MaterialTipDialog() {
            final MaterialTipDialog dialog = new MaterialTipDialog(context);
            dialog//
                    // .isTitleShow(false)//
                    .content("为保证咖啡豆的新鲜度和咖啡的香味,并配以特有的传统烘焙和手工冲。")//
                    .btnText("确定")//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();

            dialog.setOnBtnClickL(new OnBtnClickL() {
                @Override
                public void onBtnClick() {
                    dialog.dismiss();
                }
            });
        }

        private void NormalListDialog() {
            final NormalListDialog dialog = new NormalListDialog(context, testItems);
            dialog.title("请选择")//
                    .showAnim(bas_in)//
                    .dismissAnim(bas_out)//
                    .show();
            dialog.setOnOperItemClickL(new OnOperItemClickL() {
                @Override
                public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                    T.showShort(context, testItems.get(position).operName);
                    dialog.dismiss();
                }
            });
        }


        private void NormalListDialogCustomAttr() {
            final NormalListDialog dialog = new NormalListDialog(context, testItems);
            dialog.title("请选择")//
                    .titleTextSize_SP(18)//
                    .titleBgColor(Color.parseColor("#409ED7"))//
                    .itemPressColor(Color.parseColor("#85D3EF"))//
                    .itemTextColor(Color.parseColor("#303030"))//
                    .itemTextSize(14)//
                    .cornerRadius(0)//
                    .widthScale(0.8f)//
                    .show(R.style.myDialogAnim);

            dialog.setOnOperItemClickL(new OnOperItemClickL() {
                @Override
                public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                    T.showShort(context, testItems.get(position).operName);
                    dialog.dismiss();
                }
            });
        }


        private void NormalListDialogNoTitle() {
            final NormalListDialog dialog = new NormalListDialog(context, testItems);
            dialog.title("请选择")//
                    .isTitleShow(false)//
                    .itemPressColor(Color.parseColor("#85D3EF"))//
                    .itemTextColor(Color.parseColor("#303030"))//
                    .itemTextSize(15)//
                    .cornerRadius(2)//
                    .widthScale(0.75f)//
                    .show();

            dialog.setOnOperItemClickL(new OnOperItemClickL() {
                @Override
                public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                    T.showShort(context, testItems.get(position).operName);
                    dialog.dismiss();
                }
            });
        }

        private void NormalListDialogStringArr() {
            final NormalListDialog dialog = new NormalListDialog(context, stringItems);
            dialog.title("请选择")//
                    .show(R.style.myDialogAnim);
            dialog.setOnOperItemClickL(new OnOperItemClickL() {
                @Override
                public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                    T.showShort(context, testItems.get(position).operName);
                    dialog.dismiss();
                }
            });
        }

        private void NormalListDialogAdapter() {
            final NormalListDialog dialog = new NormalListDialog(context, new TestAdapter(context, testItems));
            dialog.title("请选择")//
                    .show(R.style.myDialogAnim);
            dialog.setOnOperItemClickL(new OnOperItemClickL() {
                @Override
                public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                    T.showShort(context, testItems.get(position).operName);
                    dialog.dismiss();
                }
            });
        }


        private void ActionSheetDialog() {
            final String[] stringItems = {"接收消息并提醒", "接收消息但不提醒", "收进群助手且不提醒", "屏蔽群消息"};
            final ActionSheetDialog dialog = new ActionSheetDialog(context, stringItems, null);
            dialog.title("选择群消息提醒方式\r\n(该群在电脑的设置:接收消息并提醒)")//
                    .titleTextSize_SP(14.5f)//
                    .show();

            dialog.setOnOperItemClickL(new OnOperItemClickL() {
                @Override
                public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                    T.showShort(context, stringItems[position]);
                    dialog.dismiss();
                }
            });
        }

        private void ActionSheetDialogNoTitle() {
            final String[] stringItems = {"版本更新", "帮助与反馈", "退出QQ"};
            final ActionSheetDialog dialog = new ActionSheetDialog(context, stringItems, elv);
            dialog.isTitleShow(false).show();

            dialog.setOnOperItemClickL(new OnOperItemClickL() {
                @Override
                public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) {
                    T.showShort(context, stringItems[position]);
                    dialog.dismiss();
                }
            });
        }

Custom Dialog(自定义Dialog)

  • extends BaseDialog(继承BaseDialog)
  • create layout and find views in method onCreateView(在onCreateView方法填充布局和查找控件)
  • do some logic operation in method setUiBeforShow , return false go on to show dialog else return true don't(在setUiBeforShow方法中做一些逻辑操作,返回值false显示dialog,返回值true不显示)
public class CustomBaseDialog extends BaseDialog {
    private TextView tv_cancel;
    private TextView tv_exit;

    public CustomBaseDialog(Context context) {
        super(context);
    }

    @Override
    public View onCreateView() {
        widthScale(0.85f);
        showAnim(new Swing());

        // dismissAnim(this, new ZoomOutExit());
        View inflate = View.inflate(context, R.layout.dialog_custom_base, null);
        tv_cancel = ViewFindUtils.find(inflate, R.id.tv_cancel);
        tv_exit = ViewFindUtils.find(inflate, R.id.tv_exit);
        inflate.setBackgroundDrawable(
                CornerUtils.cornerDrawable(Color.parseColor("#ffffff"), dp2px(5)));

        return inflate;
    }

    @Override
    public boolean setUiBeforShow() {
        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        tv_exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        return false;
    }
}

Custom Animation(自定义动画)

Here is an example that custom animation in custom dialog.You can also just custom animtaion for showAnim() and dismissAnim() method.(下面例子是在自定Dialog内部中自定义动画,你也可以只是自定义动画给showAnim和dismissAnim方法调用)

public class IOSTaoBaoDialog extends BottomBaseDialog {
    private LinearLayout ll_wechat_friend_circle;
    private LinearLayout ll_wechat_friend;
    private LinearLayout ll_qq;
    private LinearLayout ll_sms;

    public IOSTaoBaoDialog(Context context, View animateView) {
        super(context, animateView);
    }

    public IOSTaoBaoDialog(Context context) {
        super(context);
    }

    @Override
    public View onCreateView() {
        View inflate = View.inflate(context, R.layout.dialog_ios_taobao, null);
        ll_wechat_friend_circle = ViewFindUtils.find(inflate, R.id.ll_wechat_friend_circle);
        ll_wechat_friend = ViewFindUtils.find(inflate, R.id.ll_wechat_friend);
        ll_qq = ViewFindUtils.find(inflate, R.id.ll_qq);
        ll_sms = ViewFindUtils.find(inflate, R.id.ll_sms);

        return inflate;
    }

    @Override
    public boolean setUiBeforShow() {
        ll_wechat_friend_circle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                T.showShort(context, "朋友圈");
                dismiss();
            }
        });
        ll_wechat_friend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                T.showShort(context, "微信");
                dismiss();
            }
        });
        ll_qq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                T.showShort(context, "QQ");
                dismiss();
            }
        });
        ll_sms.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                T.showShort(context, "短信");
                dismiss();
            }
        });

        return false;
    }

    private BaseAnimatorSet windowInAs;
    private BaseAnimatorSet windowOutAs;

    @Override
    protected BaseAnimatorSet getWindowInAs() {
        if (windowInAs == null) {
            windowInAs = new WindowsInAs();
        }
        return windowInAs;
    }

    @Override
    protected BaseAnimatorSet getWindowOutAs() {
        if (windowOutAs == null) {
            windowOutAs = new WindowsOutAs();
        }
        return windowOutAs;
    }

    class WindowsInAs extends BaseAnimatorSet {
        @Override
        public void setAnimation(View view) {
            ObjectAnimator rotationX = ObjectAnimator.ofFloat(view, "rotationX", 10, 0f).setDuration(150);
            rotationX.setStartDelay(200);
            animatorSet.playTogether(
                    ObjectAnimator.ofFloat(view, "scaleX", 1.0f, 0.8f).setDuration(350),
                    ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 0.8f).setDuration(350),
//                    ObjectAnimator.ofFloat(view, "alpha", 1.0f, 0.5f).setDuration(350),
                    ObjectAnimator.ofFloat(view, "rotationX", 0f, 10).setDuration(200),
                    rotationX,
                    ObjectAnimator.ofFloat(view, "translationY", 0, -0.1f * dm.heightPixels).setDuration(350)
            );
        }
    }

    class WindowsOutAs extends BaseAnimatorSet {
        @Override
        public void setAnimation(View view) {
            ObjectAnimator rotationX = ObjectAnimator.ofFloat(view, "rotationX", 10, 0f).setDuration(150);
            rotationX.setStartDelay(200);
            animatorSet.playTogether(
                    ObjectAnimator.ofFloat(view, "scaleX", 0.8f, 1.0f).setDuration(350),
                    ObjectAnimator.ofFloat(view, "scaleY", 0.8f, 1.0f).setDuration(350),
//                    ObjectAnimator.ofFloat(view, "alpha", 1.0f, 0.5f).setDuration(350),
                    ObjectAnimator.ofFloat(view, "rotationX", 0f, 10).setDuration(200),
                    rotationX,
                    ObjectAnimator.ofFloat(view, "translationY", -0.1f * dm.heightPixels, 0).setDuration(350)
            );
        }
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,905评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,140评论 2 379
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,791评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,483评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,476评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,516评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,905评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,560评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,778评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,557评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,635评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,338评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,925评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,898评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,142评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,818评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,347评论 2 342

推荐阅读更多精彩内容