How to apply the shadow to the status bar on opening a bottom sheet in Compose?

Viewed 442

I'm trying to use Compose to apply the shadow that's applied to the background when you open a bottom sheet to the status bar as well, example here (Google News app). The whole background, including the status bar gets a shadow, but I can't replicate the same behaviour in a simple app. I've bee using the ModalBottomSheetLayout composable to invoke the bottom sheet.

Google News app with a bottom sheet opened

I've tried using the accompanist library and its System UI Controller to set the color of the status bar to Transparent, but maybe I'm misunderstanding what that's meant to do, as the status bar just remains white and unchanged when the bottom sheet is opened.

How can I put the status bar "in the background" as well when a bottom sheet is opened?

1 Answers

Call this in onCreate function;

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        //Call this
        WindowCompat.setDecorFitsSystemWindows(window, false)

        setContent {

            AppTheme {

                MainScreen()
            }
        }
    }
}
Related