android对话框 - 设置背景图像的不透明度

时间:2011-11-14 20:11:13

标签: android

我有一个出现在SurfaceView顶部的对话框。我希望对话框有一个自定义图像作为其背景,但我还想使图像稍微透明,以便您可以在下面看到。

关于如何更改图像的不透明度的任何想法?

gameover.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/dialog"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/imagebackground"
    android:orientation="vertical" >

来自父活动的创建代码

    gameOverDialog = new Dialog(this);
    gameOverDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    gameOverDialog.setContentView(R.layout.gameover);

1 个答案:

答案 0 :(得分:1)

您可能需要在创建图像时为图像添加alpha(在Photoshop中...等等)。但是你也可以尝试将背景图像作为Drawable并在其上调用setAlpha来获得你想要的东西。 http://developer.android.com/reference/android/graphics/drawable/Drawable.html#setAlpha(int

相关问题