Again n again🤩, thanks to @Joseinnewworld
— Gaexe (@gaexe_) May 25, 2025
for sweeping several of my #NFTs! 🙌 #NFTCollectors #NFT进化 #NFTCollection #eCash Network https://t.co/n2yHqeSzgZ pic.twitter.com/hwrzPADAgj
I have a MainActivity with multiple Fragments and in one particular Fragment I want to draw behind the system bar, so I apply the following flag at runtime
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}What I want now is when the user exits this Fragment and enters another one to remove that flag so that there is no content behind the status bar. I tried passing null as an argument to the setFlags() method but it gives an error. I have looked for a remove() or unSet() method but there is none. So how should I remove that flag for another Fragment?
Solution
This is an outdated way
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)The latest way
Use
Window#setStatusBarColor(int)a semi-transparent color instead.
After declaring the color with the hex value #6F000000, then in the code:
getWindow().setStatusBarColor(ContextCompat.getColor(context, R.color.my_color))
