仿IOS制作的一套Android组件
1. Dialog
使用方式:
implementation 'com.github.majdalden:android-ios-like-dialog:0.2.0'
1.1 普通弹窗
使用方式:
new DialogNormal(this)
.setTitle("标题")
.setTitleClickListener(v2 -> {
Toast.makeText(this, "点击标题", Toast.LENGTH_SHORT).show();
})
.setContent("内容", v2 -> {
Toast.makeText(this, "点击内容", Toast.LENGTH_SHORT).show();
})
.setConfirm("确定", v2 -> {
Toast.makeText(this, "点击确定", Toast.LENGTH_SHORT).show();
})
.setCancel("取消", v2 -> {
Toast.makeText(this, "点击取消", Toast.LENGTH_SHORT).show();
}, false)
.setCancelStyle(new DialogTextStyle.Builder(this).color(R.color.ios_like_green).typeface(Typeface.create(Typeface.MONOSPACE, Typeface.BOLD_ITALIC)).build())
.setConfirmStyle(new DialogTextStyle.Builder(this).color(R.color.ios_like_purple).typeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC)).build())
.setCanceledOnTouchOutside(true)
.show();
详细使用见demo DialogNormalActivity.
效果:
1.2 底部弹窗
使用方式:
new DialogBottom(this)
.setTitle("标题", v2 -> {
Toast.makeText(this, "点击标题", Toast.LENGTH_SHORT).show();
})
.setCancel("取消", v2 -> {
Toast.makeText(this, "点击取消", Toast.LENGTH_SHORT).show();
}, false)
.setCancelStyle(new DialogTextStyle.Builder(this).color(R.color.ios_like_green).typeface(Typeface.create(Typeface.MONOSPACE, Typeface.BOLD_ITALIC)).build())
.addBottomItem("按钮1", v2 -> Toast.makeText(this, "点击按钮1", Toast.LENGTH_SHORT).show(), new DialogTextStyle.Builder(this).color(R.color.ios_like_pink).typeface(Typeface.create(Typeface.MONOSPACE, Typeface.BOLD_ITALIC)).build())
.addBottomItem("按钮2", new DialogTextStyle.Builder(this).color(R.color.ios_like_purple).textSize(20).typeface(Typeface.create(Typeface.MONOSPACE, Typeface.BOLD_ITALIC)).build())
.setCanceledOnTouchOutside(true)
.show();
详细使用见demo DialogBottomActivity.
效果:
1.3 hud弹窗
使用方式:
new DialogHud(this)
.setMode(DialogHud.Mode.LOADING)
.setLabel("Please wait...")
.setLabelDetail("downloading...")
.setCanceledOnTouchOutside(true)
.setAutomaticDisappear(true)
.show();
详细使用见demo DialogHudActivity.
效果: