Why in Android studio my virtual machine doesn´t match with the android layout design? And I already disable the status bar

Viewed 20

When I launch my virtual machine it doesn´t match with the layout, it seems that I have activated the status bar but I already disabled in the theme.xml

The code of the layout:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white"
tools:context=".MainActivity">

And I already disable the status bar, here´s the code of the theme.xml:

<style name="Theme.Ev" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <!-- Hiding the ActionBar with the parent -->
    <item name="colorPrimary">@color/logo_colorblack</item>
    <item name="colorPrimaryVariant">@color/logo_colorblack</item>
    <item name="colorOnPrimary">@color/logo_colorblack</item>
    <item name="colorSecondary">@color/teal_200</item>
    <item name="colorSecondaryVariant">@color/teal_700</item>
    <item name="colorOnSecondary">@color/black</item>
    <item name="android:statusBarColor">@color/gray_pewter</item>
</style>

Here is the image of my project: comparison

Thank you for reading this.

1 Answers

First lets go through the differences of Status Bar and Toolbar.

Status bar: On Android, the status bar contains notification icons and system icons. enter image description here

Toolbar/top app bar/Action bar: Display information and actions at the top of a screen. enter image description here

You've set your app to inherit from Theme.MaterialComponents.DayNight.NoActionBar which means the action bar is disabled, but that doesn't mean the status bar won't be shown.

To hide the status bar in your application, follow this quick official guide from Google: https://developer.android.com/training/system-ui/status

Related