一個Android對話框的庫內(nèi)置自帶一些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(默認內(nèi)置自帶Dialog)

Here's the dialog usages corresponding to the demo listview item sort.(下面dialog使用方法和Demo中的列表順序?qū)?yīng))


    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("為保證咖啡豆的新鮮度和咖啡的香味,并配以特有的傳統(tǒng)烘焙和手工沖重斑。")//
                    .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("繼續(xù)逛逛")//
                    .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("繼續(xù)逛逛")//
                    .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 年發(fā)布的 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("為保證咖啡豆的新鮮度和咖啡的香味砰盐,并配以特有的傳統(tǒng)烘焙和手工沖闷袒。")//
                    .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("為保證咖啡豆的新鮮度和咖啡的香味,并配以特有的傳統(tǒng)烘焙和手工沖岩梳。")//
                    .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(該群在電腦的設(shè)置:接收消息并提醒)")//
                    .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內(nèi)部中自定義動畫,你也可以只是自定義動畫給showAnim和dismissAnim方法調(diào)用)

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)
            );
        }
    }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末囊骤,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子冀值,更是在濱河造成了極大的恐慌也物,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,123評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件列疗,死亡現(xiàn)場離奇詭異滑蚯,居然都是意外死亡,警方通過查閱死者的電腦和手機抵栈,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,031評論 2 384
  • 文/潘曉璐 我一進店門告材,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人古劲,你說我怎么就攤上這事斥赋。” “怎么了产艾?”我有些...
    開封第一講書人閱讀 156,723評論 0 345
  • 文/不壞的土叔 我叫張陵疤剑,是天一觀的道長滑绒。 經(jīng)常有香客問我,道長隘膘,這世上最難降的妖魔是什么疑故? 我笑而不...
    開封第一講書人閱讀 56,357評論 1 283
  • 正文 為了忘掉前任,我火速辦了婚禮棘幸,結(jié)果婚禮上焰扳,老公的妹妹穿的比我還像新娘倦零。我一直安慰自己误续,他們只是感情好,可當我...
    茶點故事閱讀 65,412評論 5 384
  • 文/花漫 我一把揭開白布扫茅。 她就那樣靜靜地躺著蹋嵌,像睡著了一般。 火紅的嫁衣襯著肌膚如雪葫隙。 梳的紋絲不亂的頭發(fā)上栽烂,一...
    開封第一講書人閱讀 49,760評論 1 289
  • 那天,我揣著相機與錄音恋脚,去河邊找鬼腺办。 笑死,一個胖子當著我的面吹牛糟描,可吹牛的內(nèi)容都是我干的怀喉。 我是一名探鬼主播,決...
    沈念sama閱讀 38,904評論 3 405
  • 文/蒼蘭香墨 我猛地睜開眼船响,長吁一口氣:“原來是場噩夢啊……” “哼躬拢!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起见间,我...
    開封第一講書人閱讀 37,672評論 0 266
  • 序言:老撾萬榮一對情侶失蹤聊闯,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后米诉,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體菱蔬,經(jīng)...
    沈念sama閱讀 44,118評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,456評論 2 325
  • 正文 我和宋清朗相戀三年史侣,在試婚紗的時候發(fā)現(xiàn)自己被綠了拴泌。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,599評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡抵窒,死狀恐怖弛针,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情李皇,我是刑警寧澤削茁,帶...
    沈念sama閱讀 34,264評論 4 328
  • 正文 年R本政府宣布宙枷,位于F島的核電站,受9級特大地震影響茧跋,放射性物質(zhì)發(fā)生泄漏慰丛。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,857評論 3 312
  • 文/蒙蒙 一瘾杭、第九天 我趴在偏房一處隱蔽的房頂上張望诅病。 院中可真熱鬧,春花似錦粥烁、人聲如沸贤笆。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,731評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽芥永。三九已至,卻和暖如春钝吮,著一層夾襖步出監(jiān)牢的瞬間埋涧,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,956評論 1 264
  • 我被黑心中介騙來泰國打工奇瘦, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留棘催,地道東北人。 一個月前我還...
    沈念sama閱讀 46,286評論 2 360
  • 正文 我出身青樓耳标,卻偏偏與公主長得像醇坝,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子麻捻,可洞房花燭夜當晚...
    茶點故事閱讀 43,465評論 2 348

推薦閱讀更多精彩內(nèi)容