Just make a transparent full screen activity that lets touches pass through. To make touches pass through use the following Window flags before setting the contentView:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Window window = getWindow();
// Let touches go through to apps/activities underneath.
window.addFlags(FLAG_NOT_TOUCHABLE);
// Now set up content view
setContentView(R.layout.main);
}
For your main.xml layout file just use a full screen LinearLayout with a transparent background:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#33000000">
</LinearLayout>
Then to adjust the "brightness" just change the value of the background colour from your code somewhere:
findViewById(R.id.background).setBackgroundColor(0x66000000);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…