圆角的dialog还是蛮常用的,demo中正好用上了
自定义Dialog,代码中可以设置指定大小与位置
/**
* author : jiangxue
* date : 2023/9/25 13:21
* description :圆角的矩形
*/
internal class RoundCornerView(context: Context,view: Int, @StyleRes themeResId: Int) :
Dialog(context, themeResId) {
private val contentView: View
init {
// 自已定义Dialog的布局
contentView = LayoutInflater.from(context).inflate(view, null)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(contentView)
val params = window!!.attributes
params.gravity = Gravity.CENTER
window!!.attributes = params
}
//提供外部获取View的方法
fun getContentView(): View {
return contentView
}
}
设置style
<