简体   繁体   中英

Not dim previous activity when new activity is started

When I start an activity B over activity A, A is dimmed. Is it possible to not dim activity A, when activity B is started?

This can be done by creating a new style in your res/values/styles.xml file with the attribute backgroundDimEnabled set to false:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.DoNotDimBackground" parent="android:Theme">
    <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>

In your manifest, you should simply apply the newly created style to your activity, which we will call, for example, Activity1

<activity android:name=".Activity1" android:theme="@style/Theme.DoNotDimBackground">

Here is approach for custom dialog

    Window win = getWindow();

    win.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    WindowManager.LayoutParams params = win.getAttributes();
    params.dimAmount = 0;
    win.setAttributes(params);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM