Wozza
Wozza

Reputation: 622

android dialog box - setting opacity of background image

I have a dialog box which appears on top of a SurfaceView. I would like the dialog box to have a custom image as its background, but I would also like to make the image slightly transparent so you can see underneath.

Any ideas on how I can change the opacity of the image?

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" >

creation code from parent activity

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

Upvotes: 0

Views: 1212

Answers (1)

LuxuryMode
LuxuryMode

Reputation: 33741

You probably need to add alpha to the image when you create it (in photoshop...whatever). But you can also try getting the background image as a Drawable and calling setAlpha on it to get what you want. http://developer.android.com/reference/android/graphics/drawable/Drawable.html#setAlpha(int)

Upvotes: 1

Related Questions