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.
You could fade in a dialog with an opaque background.
Then just set a custom view that contains your buttons on the dialog.
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);
}
}