简体   繁体   中英

How to use SearchView from dark theme in Light Appcompat theme

I am using Theme.AppCompat.Light theme and using SearchView which by default shows dark texts and icons..

How can I use SearchView defined in Theme.AppCompat in this light theme?

Already tried below but not working?

<style name="Theme.App.Light" parent="Theme.AppCompat.Light">
   <item name="searchViewStyle">@style/Widget.AppCompat.SearchView</item>
</style> 

Even using Theme.AppCompat.Light.DarkActionBar as base theme does not show the white texts and icons..

It can be done by overriding all values,but I just need to use defaults provided in Dark theme..

Per this pro-tip , Theme.AppCompat.Light.DarkActionBar only applies if you are using the AppCompat provided Action Bar. If you are using a Toolbar , then you should be using a Theme.AppCompat.Light.NoActionBar theme. To theme your Toolbar appropriate for a dark background, you need to add android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" :

<android.support.v7.widget.Toolbar
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

SearchView will then pull the correct resources needed to work on a dark background.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM