Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Action bar content is not hiding

so i want to use toolbar but when i change DarkActionBar to NoActionBar in the styles,action bar doesnt remove completely and app title is on my toolbar.

https://i.stack.imgur.com/0X722.jpg

here is my xml code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<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"
tools:context=".MainActivity">


<androidx.appcompat.widget.Toolbar
    android:layout_width="match_parent"
    android:id="@+id/myToolbar"
    android:background="@color/design_default_color_primary_dark"
    android:layout_height="?attr/actionBarSize">


    <TextView
        android:layout_width="wrap_content"
        android:text="Toolbar"
        android:textSize="22sp"
        android:textColor="@color/white"
        android:textStyle="bold"
        android:layout_gravity="center"
        android:layout_height="wrap_content"
        tools:ignore="HardcodedText" />
</androidx.appcompat.widget.Toolbar>



<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

what can i do?sorry for poor english btw.

>Solution :

i think you have in MainActivity code like this and you got the result as shown in the screenshot

setSupportActionBar(myToolbar)

just remove this line or add app:title=" " tag

<androidx.appcompat.widget.Toolbar
        android:layout_width="match_parent"
        android:id="@+id/myToolbar"
        app:title=" "
        android:background="@color/design_default_color_primary_dark"
        android:layout_height="?attr/actionBarSize">


        <TextView
            android:layout_width="wrap_content"
            android:text="Toolbar"
            android:textSize="22sp"
            android:textColor="@color/white"
            android:textStyle="bold"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            tools:ignore="HardcodedText" />
    </androidx.appcompat.widget.Toolbar>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading