material-components / material-components/material-components-android

[MaterialToolbar] SearchView text/hint not using colorOnPrimary

Open
#1,396 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Widget: TopAppBar
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:**
When having the following layout defining the toolbar:
```

```
The colors of the Toolbar (title, subtitle, icons, ...) are set correctly to `?attr/colorOnPrimary`. However, the text and hint of the SearchView are not.

**Expected behavior:**
I would expect the colors of the SearchView to be the same as the tile/subtitle of the Toolbar.

**Source code:**
The definition of [ThemeOverlay.MaterialComponents.Toolbar.Primary](https://github.com/material-components/material-components-android/blob/712a2ce92040b6fc90530ad853633ecd7f258dfc/lib/java/com/google/android/material/appbar/res/values/styles.xml#L77-L80) is missing the color settings for the SearchView:
```

<item name="colorControlNormal">?attr/colorOnPrimary</item>
<item name="actionMenuTextColor">?attr/colorOnPrimary</item>

```
When overriding the default ThemeOverlay with the following, it works fine:
```

<item name="android:editTextColor">?attr/colorOnPrimary</item>
<item name="android:textColorHint">?attr/colorOnPrimary</item>

```
**Android API version:** 29

**Material Library version:** com.google.android.material:material:1.1.0

**Device:**
- Emulator
- Nokia 1

To help us triage faster, please check to make sure you are using the [latest version](https://github.com/material-components/material-components-android/releases) of the library.

We also happily accept [pull requests](https://github.com/material-components/material-components-android/pulls).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/java/com/google/android/material/appbar/res/values/styles.xml, specifically ThemeOverlay.MaterialComponents.Toolbar.Primary and its existing color settings. Verify the SearchView text and hint colors under this overlay, then confirm that they match the toolbar title and subtitle colors.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.