现象:该设的属性都设了,但是还是有一层背景去不掉,如图
解决方案:递归去除背景,代码如下:
@Override public void onStart() { super.onStart(); View view=getDialog().getWindow().getDecorView(); clearBackground(view); } private void clearBackground(View view) { if (!(view instanceof ViewGroup)) { view.setBackground(null); return; } if(view.getId()==R.id.parentId) return; for (int i=0;i<((ViewGroup) view).getChildCount();i++) { view.setBackground(null); clearBackground(((ViewGroup) view).getChildAt(i)); } }
本文介绍了一种通过递归方式清除安卓应用中对话框背景的方法。针对无法直接移除背景的问题,提供了一段示例代码,从根视图开始递归地遍历并清空所有子视图的背景。
1055

被折叠的 条评论
为什么被折叠?



