Android 将带有ImageView的自定义布局的背景设置为透明

Android 将带有ImageView的自定义布局的背景设置为透明,android,android-layout,android-dialog,Android,Android Layout,Android Dialog,我正在使用Android开发者文档构建一个自定义对话框,为此我制作了一个布局文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rotatelayout" android:layout_width="wrap_content" android:layout_height

我正在使用Android开发者文档构建一个自定义对话框,为此我制作了一个布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rotatelayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#80000000"
>

<ImageView 
    android:id="@+id/dialogimage"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
</LinearLayout>
但它仍然看起来像

我已经尝试了堆栈溢出时提供的所有帮助

,


但是它们都不起作用,它仍然会显示出来。

尝试将此作为视图的样式:

<style name="Dialog_Fullscreen">
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowNoTitle">true</item>
</style> 

真的
真的

尝试将此作为视图的样式:

<style name="Dialog_Fullscreen">
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowNoTitle">true</item>
</style> 

真的
真的

或者您可以为此使用Dialog类

Dialog dialog = new Dialog(this,
                android.R.style.Theme_Translucent_NoTitleBar);
        Window window = dialog.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT);
        dialog.setCancelable(true);

        dialog.setCanceledOnTouchOutside(true);
        dialog.setContentView(R.layout.temp);
        dialog.show();

也可以使用Dialog类进行此操作

Dialog dialog = new Dialog(this,
                android.R.style.Theme_Translucent_NoTitleBar);
        Window window = dialog.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT);
        dialog.setCancelable(true);

        dialog.setCanceledOnTouchOutside(true);
        dialog.setContentView(R.layout.temp);
        dialog.show();

#8000000不正确您应该在线性布局中使用#00000000
android:background=“@android:color/transparent”
@user370305我也用过,但它仍然是黑色的。#8000000不正确您应该在线性布局中使用#00000000
android:background=“@android:color/transparent”
@user370305我也使用了它,但它仍然是黑色的。你能告诉我,该代码中到底是什么产生了图中的黑色背景吗?这是任何“警报”对话框的默认主题。我不知道如何从警报对话框中删除该主题,但这是我用于自定义对话框的主题,它工作正常。您能告诉我该代码中到底是什么产生了图中的黑色背景吗?这是任何“警报”对话框的默认主题。我不知道如何从“警报”对话框中删除主题,但这是我用于自定义对话框的内容,它工作正常。