Search code examples
androidkotlinandroid-actionbar

Hide action bar immediately when open android app


After research in goole, I can hide action bar but the current result is the action bar still show few seconds before open MainActivity. You can refer in the gif below.

My question is can we hide action bar immediately when launch app?

Here's my source code

enter image description here


Solution

  • I change theme like below

        <style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowActionBar">false</item>
            <item name="android:windowFullscreen">true</item>
            <item name="android:windowContentOverlay">@null</item>
            <item name="android:windowIsTranslucent">true</item>
        </style>
    

    In AndroidManifest.xml

    <activity
         android:name=".MainActivity"
         android:exported="true"
         android:label="@string/app_name"
         android:theme="@style/Theme.Transparent">
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />
             <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
    </activity>
    

    And the result:

    enter image description here

    I also commit new source code to HERE if anyone needed