开源-仿IOS弹出框 SheetDialog

SheetDialog , 仿造IOS 风格底部弹出的样式,通用的Dialog

Overview

仿ios底部弹出

通用的dialog

Download

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

1
2
3
4
5
allprojects {
repositories {
maven { url 'https://www.jitpack.io' }
}
}

Step 2. Add the dependency

1
2
3
dependencies {
implementation 'com.github.JiangHaiYang01:SheetDialog:0.0.2'
}

当前最新版本

Usage

仿ios 的底部弹出效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SheetDialog(this)
.create()
.setTitle("请选择") //title 提示
.setCancelTvColor(Color.RED)//设置cancel 颜色
.setCancelTvMsg("取消") //设置cancel 文案
.setCancelTvSize(16f)//设置cancel 字体大小
.addSheetItem("照片", object : OnSheetItemClickListener() {
override fun onSheetItemClick() {
Toast.makeText(this@MainActivity, "照片", Toast.LENGTH_SHORT).show()
}
})
.addSheetItem("拍照", object : OnSheetItemClickListener() {
override fun onSheetItemClick() {
Toast.makeText(this@MainActivity, "拍照", Toast.LENGTH_SHORT).show()
}
})
.setCancelTvMsg("取消")
.show()

通用的dialog

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
GeneralDialog(this)
.create()
.setTitle("请输入手机号")
//取消
.setNegative(object : GeneralDialog.OnNegativeListener {
override fun onNegative(dialog: GeneralDialog) {
dialog.dismiss()
}
})
//确认
.setPositive(object : GeneralDialog.OnPositiveListener {
override fun onPositive(dialog: GeneralDialog) {
dialog.dismiss()
Toast.makeText(
applicationContext,
editText.text.toString(),
Toast.LENGTH_SHORT
).show()
}
})
.setGradientRadius(40f)
//自定义的布局
.setCustomView(R.layout.dialog_custom, object : GeneralDialog.OnCustomListener {
override fun onCustom(view: View) {
editText = view.findViewById(R.id.custom_et_phone)
}
})
//添加动画
.setAnimations(R.style.ActionSheetDialogAnimation)
.show()

Github

点击查看