Android 自定义Dialog、IOS风格;

Android 自定义Dialog、IOS风格;_第1张图片

AndroidX版本、DialogFragment实现;

Kotlin代码;

IOS风格弹框、自定义弹框、底部选择弹框、加载中弹框;

使用方便,一行代码使用弹框,可以高度自定义:

https://blog.csdn.net/qq_35605213/article/details/87864905 这篇讲了DialogFragment的基本使用方法;

本项目Github地址:https://github.com/CuiChenbo/CcDialog

testBtn1.setOnClickListener {AlertDialog.show(this,"通知","APP即将崩溃","MDZZ","我知道了")}
        testBtn2.setOnClickListener {AlertDialog().bulid(this).setTitle("崔崔崔")
                .setMsg("你好")
                .setBtnR("真帅",object: OnDialogButtonClickListener {
                    override fun onClick(dialog: BaseDialog, v: View) {
                       toast("帅")
                        dialog.dismiss()
                    }
                })
                .setCancelable(false)
                .show()}

        testBtn3.setOnClickListener {LoadDialog.show(this)
        testBtn3.postDelayed(Runnable {LoadDialog.dismiss()  },3000L )
        }
        testBtn4.setOnClickListener {LoadDialog().bulid(this)
                .autoDismiss(3333)
                .setMsg("嘿嘿")
                .setMsgColor(R.color.dark)
                .setProgressColor(R.color.dark)
                .setBckRes(R.drawable.rect_selectdialog_ios_bkg_light)
                .show()
        }

        testBtn5.setOnClickListener {
            BottomDialog.show(this,"挖掘机",Arrays.asList("中国","山东","找","蓝翔"),object: OnBottomItemClick {
                override fun onItemClick(dialog: BaseDialog, position: Int) {
                    toast(position)
                    dialog.dismiss()
                }
            },false)
        }

        testBtn6.setOnClickListener {
         CustomDialog.show(this,R.layout.layout_lufei,object: OnBindView {
             override fun onBind(dialog: BaseDialog?, view: View) {
                 val imageview = view.findViewById(R.id.iv)
                 val textview = view.findViewById(R.id.tv)
                 imageview.setOnClickListener{toast("快救我出来") }
                 textview.setOnClickListener{dialog!!.dismiss() }
             }
         }, false)
        }

    }

    fun toast(obj: Any) {
        Toast.makeText(baseContext, obj.toString(), Toast.LENGTH_SHORT).show()
    }

UI风格仿照Kongzue的Dialog;

你可能感兴趣的:(Android)