Reputation: 181
How can I hide the Android action bar on certain activities such as a splash screen? I've tried changing the theme, but it changes the whole applications theme. Also leading me to some place that could help me would be great.
Upvotes: 0
Views: 244
Reputation: 4651
On the latest version of documentation I found this for Android Kotlin:
private fun hideSystemBars() {
val windowInsetsController =
ViewCompat.getWindowInsetsController(window.decorView) ?: return
// Configure the behavior of the hidden system bars
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
// Hide both the status bar and the navigation bar
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
}
https://developer.android.com/training/system-ui/immersive
Upvotes: 0
Reputation: 4066
Simple way is to add @android:style/Theme.Light.NoTitleBar
to your activity in AndroidManifest.xml
file
<activity
android:name="com.package.Activity"
android:theme="@android:style/Theme.Light.NoTitleBar" >
or you can add this line in your Activity onCreate
function
requestWindowFeature(Window.FEATURE_NO_TITLE)
there also third way to do that, it's like the first one but instead of using predefine theme you can create your own custom theme and use it
in style.xml
something like this
<style name="AppBaseTheme" parent="android:Theme.Light">
<!-- this style parent may change by any defined theme you want -->
</style>
<style name="NoActionBarTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
and use your theme in AndroidManifest.xml
<activity
android:name="com.package.Activity"
android:theme="@style/NoActionBarTheme" >
Upvotes: 4
Reputation: 3734
In onCreate of your activity add this line before setContentView(....):
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Upvotes: 0
Reputation: 12347
Put the NoActionbar derived theme on the activity
not the application
in the manifest file
Upvotes: 0