skip to Main Content

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) YouTube
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();

enter image description here

4

Answers


  1. 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)

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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);
    }
    

    }

    Login or Signup to reply.
  4. 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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search