在安卓中显示弹出框dialog时,出现图片大小偏小,弹出框两边边距过大,背景显示白色(非透明).详细情况如下对比图.
创建dialog时,指定style,在style中指定无标题并设置背景透明:
- dialog中指定style
class CustDialog(context: Context) : Dialog(context, R.style.transparentDialog) {
init {
setContentView(R.layout.dialog_layout)
setCanceledOnTouchOutside(false)
}
}
- styles.xml文件中增加如下内容:
true
@android:color/transparent
demo源代码
https://gitee.com/cxyzy1/custom_dialog/tree/master/transparentBackgroundDialog
安卓开发技术分享: https://blog.csdn.net/yinxing2008/article/details/84555061 点击关注专栏,查看最新技术分享 更多技术总结好文,请关注:「程序园中猿」