0

I would like the user to be able to click on the screen.

On click, I would like entire screen to turn opaque slowly.

Then I would like to display some buttons on the opaque screen.

What is the best way to achieve this effect?

Thanks.

the_prole
  • 8,275
  • 16
  • 78
  • 163

3 Answers3

1

You could fade in a dialog with an opaque background.
Then just set a custom view that contains your buttons on the dialog.

1

Here are some options I found

ViewSwticher

CrossFade

edit

I found this method to be ideal for cross-fading layouts.

Community
  • 1
  • 1
the_prole
  • 8,275
  • 16
  • 78
  • 163
-1

You can simply change the alpha level of the activity's background in order to give it an opaque effect.

View backgroundimage = findViewById(R.id.my_activity);
Drawable background = backgroundimage.getBackground();
background.setAlpha(50);

To make it appear to "fade out", you could easily implement this into a for loop, allowing the thread to sleep for a short time between intervals to create an animated effect.

Here is a quick design of what this function might look like:

void fadeView(View v, int threshold, int speed) {
    Drawable background = v.getBackground();

    for (int i = 100; i < threshold; i--) {
        background.setAlpha(i);
        Thread.sleep(speed);
    }
}
Shane Duffy
  • 1,117
  • 8
  • 18