What is the default color to populate the dialog box?

When Android AlertDialogshows, the background around this dialog gets darker. This is probably achieved by first filling the entire screen with a translucent color, and then placing the dialog on top of it.

My question is: what is the default color for this background?

#88666666 //looks close, but not enough
+11
source share
4 answers

If you check the AppCompat Dialog, I believe that it uses:

<color name="dim_foreground_disabled_material_dark">#80bebebe</color>
<color name="dim_foreground_disabled_material_light">#80323232</color>

However, in my own testing, I think it is #99000000(black with an opacity of 62%)

+1
source

For future readers:

, , Scrim .

, Material Design

: # 000000

: 32%

0

Try it !. It worked very well!

in onCreate ()

final int baseAlpha = (0x99000000) >>> 24;
layout.setBackgroundColor(baseAlpha);

to manifest

    <activity
        android:name=".ui.web.WebPopupActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.TransparentWebPopup" />

in style.xml

  <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowEnableSplitTouch">false</item>
    <item name="android:splitMotionEvents">false</item>
</style>

<style name="AppTheme.TransparentWebPopup" parent="AppTheme.NoActionBar">
    <item name="android:windowBackground">@color/color_trans</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>

</style>

in color.xml

 <color name="color_trans">#99000000</color>
-1
source

Try this color code # 80000000 @activity

-2
source

Source: https://habr.com/ru/post/1610919/


All Articles