I've got a simple toolbar:
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbarDriver"
app:navigationIcon="@drawable/baseline_menu_24"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
<androidx.appcompat.widget.SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:defaultQueryHint="@string/search_drivers"
app:iconifiedByDefault="false"
app:searchIcon="@null"
/>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
Which looks like this:
but when I click on the text, a random rectange appears:
How can I disable the rectange?
Your theme seems to be the issue... Try this:
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/abLayoutDriver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/BrightYellowCrayola">
Rather using android:theme which will overwrite the setting for the ENTIRE layout, put the theme content within the AppBarLayout.