Files
FocusBox/src/main/java/com/focusbox/app/ui/SheetDialog.kt
XIGE d52deeff5e 导入 v0.1.0 / v0.2.0 源码:五模块首版、交互重构、重复任务、任务分布
- 源码镜像 src/main(81 个文件):首页双模式、任务、项目、统计、设置
- 补齐 README / LICENSE / CHANGELOG / CONTRIBUTING / .gitignore
- 不含构建配置、签名材料、编译产物与备份数据
2026-11-28 00:25:22 +08:00

43 lines
1.3 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.focusbox.app.ui
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import com.focusbox.app.R
/**
* 从底部升起的弹层。
*
* 不用 Material 的 BottomSheetDialog:本工程刻意不引 Material 依赖(离线构建体积与
* 主题冲突都省了),而这里只需要"贴底 + 圆角 + 键盘顶起"三件事,自己写反而可控。
*/
open class SheetDialog(context: Context) : Dialog(context, R.style.SheetDialog) {
init {
window?.apply {
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
setGravity(Gravity.BOTTOM)
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
attributes = attributes.apply {
width = ViewGroup.LayoutParams.MATCH_PARENT
dimAmount = 0.45f
}
}
}
override fun setContentView(view: View) {
super.setContentView(view)
(view.parent as? View)?.setBackgroundColor(Color.TRANSPARENT)
}
override fun show() {
super.show()
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
}
}