Skip to content

Instantly share code, notes, and snippets.

@imandaliya
Last active March 19, 2024 05:29
Show Gist options
  • Save imandaliya/88ed432da2fd437f9172ba409d134b0f to your computer and use it in GitHub Desktop.
Save imandaliya/88ed432da2fd437f9172ba409d134b0f to your computer and use it in GitHub Desktop.
// Samsung, MI devices has extra navigation-bar
// to remove this bar
Usage:
onCreate() {
super.onCreate()
setConte......
edgeToEdge...
// then apply this
window.decorView.removeStatusAndNavigationFromDecorView()
}
// Kotlin Ex
fun View?.removeStatusAndNavigationFromDecorView(removeStatusBar: Boolean = false) {
try {
Handler(Looper.getMainLooper()).postDelayed({
(this as ViewGroup?)?.let {
for (item in 1 until it.childCount) {
try {
if(removeStatusBar) {
if(it.getChildAt(item).id == android.R.id.statusBarBackground)
it.getChildAt(item).alpha = 0f
}
if(it.getChildAt(item).id == android.R.id.navigationBarBackground)
it.getChildAt(item).alpha = 0f
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}, 200)
} catch (ignored: Exception) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment