Android的全息对话框中有2背景分层彼此顶部中有、全息、对话框、背景

2023-09-05 06:03:35 作者:酒归

该对话框看起来是这样的。有对话框本身约10-20个像素左右每一侧后面的层。我使用的主题是Theme.Holo.Dialog

The dialog looks like this. There is a layer behind the dialog itself about 10-20 pixels or so on each side. The theme I am using is Theme.Holo.Dialog

我试图创建一个透明背景的自定义对话框,但没有奏效:

I tried creating a custom dialog with a transparent background, but that did not work:

<style name="CustomHoloDialog" parent="@android:style/Theme.Holo.Dialog">
     <item name="android:background">@android:color/transparent</item>
</style>

没有人有任何想法吗?

Does anyone have any ideas on this?

推荐答案

如果你想样式对话框,那么你必须使用一个 ContextThemeWrapper

If you want to style a Dialog then you have to use a ContextThemeWrapper:

AlertDialog.Builder mBuilder = new AlertDialog.Builder(new ContextThemeWrapper(context, android.R.style.Theme_Holo_Dialog));