javaandroidhuawei-mobile-serviceshuawei-developersharmonyos

What is the alternative in HarmonyOS for window.setDimAmount() in Android?


To set the background dimness of a component like dialog box, in Android we can use the setDimAmount function.

dialog.getWindow().setDimAmount(0.5);

What is the alternative for this in HarmonyOS?


Solution

  • dialog.show();
    Optional<WindowManager.LayoutConfig> configOpt = dialog.getWindow().getLayoutConfig();
    configOpt.ifPresent(config -> {
       config.dim = 0.0f;
       dialog.getWindow().setLayoutConfig(config);
    });
    

    Just try to configure the attributes of the corresponding window after dialog.show().