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:
<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?
Advertisement
Answer
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>