Dialog+BottomSheetDialog+加载中动画,架构师花费近一年时间整理出来的安卓核心知识

var alertDialogUtils = AlertDialogUtils.build(this)
.setValues(“Title”, “Content”)
.create { view, alertDialogUtils ->
when (view.id) {
R.id.tvDialogConfig -> {
}
R.id.tvDialogCancel -> {
}
}
alertDialogUtils.dismiss()
}

自带Dialog.gif

2)、自定义ViewDialog最简单写法

AlertDialogUtils.build(this)
.setView(R.layout.dialog_curse)
.create { view, alertDialogUtils ->}

自定义ViewDialog.gif

3)、自定义ViewDialog全部属性

val alertDialogUtils = AlertDialogUtils.build(this)
.setView(R.layout.dialog_curse)//必选

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享

  自定义布局的View

.setTransparency(0.2f)//可选 默认0.2f
.setCancelable(true) //可选 默认true
.isShowKeyboard(R.id.tvDialgContent)
.setAnimator(AnimatorEnum.TRAN_T.VALUE)//可选, 默认AnimatorEnum.ZOOM.VALUE
.setOnClick(R.id.tvDialogConfig, R.id.tvDialogCancel) //可选 Dialog中的点击事件
.create { view, alertDialogUtils -> //必选 点击事件的回调
when (view.id) {
R.id.tvDialogConfig -> {
alertDialogUtils.dismiss()

}
R.id.tvDialogCancel -> {
alertDialogUtils.dismiss()
TToast.show(“tvDialogCancel”)
}
}
}

4)可选的动画

FOLD_B(R.style.zxy_fold_bottom), //折叠动画Bottom
FOLD_T(R.style.zxy_fold_top), //折叠动画Top
FOLD_L(R.style.zxy_fold_left), //折叠动画Left
FOLD_R(R.style.zxy_fold_right), //折叠动画Right
FOLD_T_NO_B(R.style.zxy_fold_top_no_bottom), //折叠动画Top,没有退出动画
ZOOM(R.style.zxy_zoom), //中心缩放动画
TRAN_B(R.style.zxy_translate_bottom), //底部弹出动画
TRAN_T(R.style.zxy_translate_top), //顶部弹出动画
TRAN_T_NO_B(R.style.zxy_translate_top_no_bottom) //顶部弹出动画,没有退出动画

5、Popwindow

注意点:如果要对Popwindow的布局进行固定的dp大小设置,就必须在外层再包裹一层布局如:

image.png

1)相对于窗口的位置的最简单的使用

PopWindowUtils.build(this)
.setView(R.layout.pop_curse) //必选
.showAtLocation({ view, popWindowUtils ->
//点击事件的回调: popWindowUtils:通过他可以拿到任何东西

}, {//销毁回调

})

窗口Pop.gif

相对于窗口的位置的全部的属性

var popWindowUtils = PopWindowUtils.build(this)
.setView(R.layout.pop_curse) //必选 设置布局
.setGravity(Gravity.TOP, 0, 0)//可选 设置方向及宽高偏移值,默认TOP
.setTransparency(1f)//可选: 默认0.5 0为全黑 1全透明
.isFocusable(false)//可选: 默认true
.isTouchable(true)//可选: 默认true
.setAnimator(AnimatorEnum.FOLD_T_NO_B.VALUE)//可选: 默认AnimatorEnum.FOLD_B.VALUE
.setTimer(3000)//可选 默认不倒计时自动销毁
.setOnClick(R.id.tvDialogConfig, R.id.tvDialogCancel)//可选: 默认没有点击事件
.showAtLocation({ view, pop ->

}, {//外部关闭回调

})

2)相对于View的位置的最简单的使用

PopWindowUtils.build(this)
.setView(R.layout.pop_curse) //必选
.showAsDropDown(btnPopWindows, { view: View, popWindowUtils: PopWindowUtils ->//点击事件的回调

}, {//外部销毁的回调

})

ViewPop.gif

3)相对于View的位置的全部属性

var popWindowUtils = PopWindowUtils.build(this)
.setView(R.layout.pop_curse) //必选 设置布局
.setGravity(Gravity.TOP, 0, 0)//可选 设置方向及宽高偏移值,默认TOP
.setTransparency(1f)//可选: 默认0.5 0为全黑 1全透明
.isFocusable(false)//可选: 默认true
.isTouchable(true)//可选: 默认true
.setAnimator(AnimatorEnum.FOLD_T.VALUE)//可选: 默认AnimatorEnum.FOLD_B.VALUE
.setTimer(3000)//可选 默认不倒计时自动销毁
.setOnClick(R.id.tvDialogConfig, R.id.tvDialogCancel)//可选: 默认没有点击事件
.showAsDropDown(it, { view, pop ->
{

}
}, { //点击外部销毁Pop的监听

})

4)可选的动画

FOLD_B(R.style.zxy_fold_bottom), //折叠动画Bottom
FOLD_T(R.style.zxy_fold_top), //折叠动画Top
FOLD_L(R.style.zxy_fold_left), //折叠动画Left
FOLD_R(R.style.zxy_fold_right), //折叠动画Right
FOLD_T_NO_B(R.style.zxy_fold_top_no_bottom), //折叠动画Top,没有退出动画
ZOOM(R.style.zxy_zoom), //中心缩放动画
TRAN_B(R.style.zxy_translate_bottom), //底部弹出动画
TRAN_T(R.style.zxy_translate_top), //顶部弹出动画
TRAN_T_NO_B(R.style.zxy_translate_top_no_bottom) //顶部弹出动画,没有退出动画
6、BottomSheetDialog底部弹出框,可以滑动(弹出框的根布局必须是-线性布局)

BottomSheetDialogUtils.build(this)
.setView(R.layout.zxy_bottom_sheet_dialog)
.setMinHeight(0.8f)//弹出框的占屏幕的高度比例


BottomSheetDialogUtils.build(this)
.setView(R.layout.zxy_bottom_sheet_dialog)
.setMinHeight(0.8f)//弹出框的占屏幕的高度比例

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值