fix
lmw
2024-11-09 d1a9e3312387b6c47e6186af506787a8a66369d1
xldutils-kotlin/src/main/java/cn/sinata/xldutils/utils/Extends.kt
@@ -9,6 +9,7 @@
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import cn.sinata.xldutils.R
import org.jetbrains.anko.dip
/**
 * 扩展方法:允许DialogFragment使用 commitAllowingStateLoss 弹窗
@@ -31,3 +32,14 @@
    toast.view = toastLayout
    toast.show()
}
fun Context.whiteToast(message: CharSequence,longTime:Boolean=false) {
    val toast = Toast(this)
    toast.duration = if (longTime)Toast.LENGTH_LONG else Toast.LENGTH_SHORT
    toast.setGravity(Gravity.CENTER, 0, dip(100))
    val toastLayout = LayoutInflater.from(this).inflate(R.layout.layout_white_toast, null)
    val txtToast: TextView = toastLayout.findViewById(R.id.txt_toast)
    txtToast.text = message
    toast.view = toastLayout
    toast.show()
}