Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the "up" button when the searchView is being expanded?

Background

My app has the ability to search for items (which are other apps) using the SearchView on the ActionBar.

The app uses the support library of Google, and it works well on all versions of Android from API 9 .

The problem

On Lollipop, when I click the search action item in order to start searching, I notice that the up/back button on the top-left corner gets to be white, which is bad for this case since the actionbar background is also quite white:

enter image description here

Weird thing is that it doesn't always occur, and I don't think it occurs on Android versions that aren't Lollipop (tested on multiple emulators and devices).

Another weird thing is that the navigation drawer icon seems ok, as well as the X icon inside the searchView.

Here's the XML of the toolbar I have:

<android.support.v7.widget.Toolbar
    android:id="@+id/activity_app_list__toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize" />

the "colorPrimary" is set to be : #ffEFEFEF .

Also, the theme's parent of the activity is "Theme.AppCompat.Light.NoActionBar" , as I've set the toolbar to be the actionBar.

The question

How can I fix this issue?

What is the cause for this issue? How come it works fine on other Android versions?

like image 502
android developer Avatar asked Dec 07 '14 22:12

android developer


1 Answers

It seems like a known issue: https://code.google.com/p/android/issues/detail?id=78346 .

workaround is here: https://code.google.com/p/android/issues/detail?id=78346#c5 , meaning:

values-21/themes.xml:

<style name="MyTheme" parent="Theme.AppCompat">
    <item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
</style>

That's it. Hope it gets fixed later.

In order to customize it, I assume I can use it, and also choose the color using "colorControlNormal"

like image 53
android developer Avatar answered Oct 07 '22 01:10

android developer