The source code
rendering
Gradle
The latest version number is here, Step 1
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.zxyUncle:DialogDemo:latest.release'
}
Copy the code
1. Plain Toast
Ttoast. show(" Please enter the correct mobile number ") ttoast. show(layoutView)// Customize the layoutCopy the code
2. Toast pops up at the top
Ztoast.setcolori ("#000000")// Optionally set the pop-up color ztoast.showi (this," network error ")Copy the code
3. A pop-up box is displayed during loading
Loadingtool. show(this," loading..." )// displays loadingTool.hide ()// hideCopy the code
4, the Dialog
1) System Dialog:
var alertDialogUtils = AlertDialogUtils.build(this)
.setValues("Title", "Content")
.create { view, alertDialogUtils ->
when (view.id) {
R.id.tvDialogConfig -> {
}
R.id.tvDialogCancel -> {
}
}
alertDialogUtils.dismiss()
}
Copy the code
2) The simplest way to customize a ViewDialog
AlertDialogUtils.build(this)
.setView(R.layout.dialog_curse)
.create { view, alertDialogUtils ->}
Copy the code
3) Customize all ViewDialog properties
Val alertDialogUtils = alertdialogutils.build (this).setview (r.layout.dialog_curse)// Mandatory View for custom layout .setTransparency(0.2f)// Optional default 0.2f. SetCancelable (true) // Optional default true. IsShowKeyboard (R.idvDialgContent) SetAnimator (VALUE) AnimatorEnum. TRAN_T. / / optional, Default animatorenum.zoom.value. setOnClick(r.idvdialogConfig, R.idvdialogCancel) // Optional Dialog click event. Create {view, AlertDialogUtils -> when (view.id) {r.idvdialogConfig -> {alertdialogutils.dismiss ()} R.id.tvDialogCancel -> { alertDialogUtils.dismiss() TToast.show("tvDialogCancel") } } }Copy the code
4) Optional animation
FOLD_B(r.style.zxy_fold_bottom), // Top 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), // Fold animation Top without exiting animation ZOOM(r.style.zxy_zoom), // Center ZOOM animation TRAN_B(R.style.zxy_translate_bottom), // TRAN_T(r.style.zxy_translate_top) pops up at the bottom, // TRAN_T_NO_B(r.style.zxy_translate_top_no_bottom) pops up at the top without exiting the animationCopy the code
5, Popwindow
Note: If you want to set a fixed DP size for the Popwindow layout, you must wrap another layer around the layout as follows:
1) The simplest use relative to the position of the window
Popwindowutils.build (this).setView(r.layout.pop_curse) // Mandatory. ShowAtLocation ({view, PopWindowUtils -> }, {// destroy the callback})Copy the code
All properties relative to the position of the window
Var popWindowUtils = popwindowutils.build (this).setView(r.layout.pop_curse) 0)// Optional top.setTransparency (1f)// Optional: default 0 is black. IsFocusable (false)// Optional: Default true. IsTouchable (true)// Optional: Default true. SetAnimator (animatorenum.fold_t_no_B.value)// Optional: Default animatorenum.foldbb.value.setTimer (3000)// Optional default no countdown destruction.setonclick (R.idvdialogConfig, R.idvdialogCancel)// Optional: ShowAtLocation ({view, pop ->}, {// External close callback})Copy the code
2) Simplest use relative to View position
SetView (r.layout.pop_curse) // mandatory. ShowAsDropDown (btnPopWindows, {view: View, popWindowUtils: popWindowUtils ->// Click event callback}, {// external destruction callback})Copy the code
3) All properties of the position relative to the View
Var popWindowUtils = popwindowutils.build (this).setView(r.layout.pop_curse) 0)// Optional top.setTransparency (1f)// Optional: default 0 is black. IsFocusable (false)// Optional: Default true. IsTouchable (true)// Optional: default true. SetAnimator (animatorenum.fold_t.value)// Optional: Default animatorenum.foldbb.value.setTimer (3000)// Optional default no countdown destruction.setonclick (R.idvdialogConfig, R.idvdialogCancel)// Optional: ShowAsDropDown (it, {view, pop -> {}}, {// click external destroy pop listener})Copy the code
4) Optional animation
FOLD_B(r.style.zxy_fold_bottom), // Top 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), // Fold animation Top without exiting animation ZOOM(r.style.zxy_zoom), // Center ZOOM animation TRAN_B(R.style.zxy_translate_bottom), // TRAN_T(r.style.zxy_translate_top) pops up at the bottom, // TRAN_T_NO_B(r.style.zxy_translate_top_no_bottom) pops up at the top without exiting the animationCopy the code
BottomSheetDialog popup box at the bottom, you can slide (popup box root layout must be -linear layout)
BottomSheetDialogUtils. Build (this). SetView (R.l ayout. Zxy_bottom_sheet_dialog). SetMinHeight popup (0.8 f) / / account for high proportion of the screen. The show ({ // Destroy listener})Copy the code
7, scan bar code, qr code, select bar code, QR code from the album
Inherit ZXingActivity and rewrite the result as executereslt, or copy the contents of ZXingActivity and place them in a new activity with your own layout