Home > Mobile >  How to remove purple header from the android app
How to remove purple header from the android app

Time:03-14

I am strugling with removing this purple header from the android app. Tried following 2 solution, but none of them worked for me.

  1. Change the style -> parent in style.xml

<style name="Theme.MaxCogito" parent="Theme.AppCompat.Light.NoActionBar">

  1. Adding following code to onCreate() (this code actually broke my code) enter image description here

    CodePudding user response:

    That "Purple bar" is called as the status bar. If you would like to hide it,

    <application
        ...
        android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    </application>
    

    For API_LEVEL < 16

    getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN
    );
    

    For API_Level >= 16

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
    getActionBar().hide(); 
    

    Your code doesn't works because you API Level is newer than 16 (probably)

    CodePudding user response:

    Add the following code inside MainActivity under the onCreate method:

    window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
    

    This requests the OS to change the visibility of the status bar to be hidden.

    CodePudding user response:

    In your onCreate method just add this In Kotlin

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // If the Android version is lower than Jellybean, use this call to hide
        // the status bar.
        if (Build.VERSION.SDK_INT < 16) {
            window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN)
        }
        setContentView(R.layout.activity_main)
    }
    

    In Java

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // If the Android version is lower than Jellybean, use this call to hide
        // the status bar.
        if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
        setContentView(R.layout.activity_main);
    }
    

    }

    CodePudding user response:

    Use that inside the styles of theme you are using.

    <resources xmlns:tools="http://schemas.android.com/tools">
        <!-- Base application theme. -->
        <style name="m_ammar_tentwenty" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
            <!-- Primary brand color. -->
            <item name="colorPrimary">@color/app_light_gray</item>
            <item name="colorPrimaryVariant">@color/app_white</item>
            <item name="colorOnPrimary">@color/app_white</item>
    
            <!-- Status bar = responsible for the background color. -->
            <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
            <!-- Status bar text colors handle from here -->
            <item name="android:windowLightStatusBar" tools:ignore="NewApi">true</item>
    
            <!-- Customize your theme here. -->
    
    
        </style>
    </resources>
    
  • Related