本文介绍了主题在动作条搜索查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索查看动作条

搜索查看图标为黑色,和文字为黑色,而过我的图标是白色的!

This SearchView icon is black, and text is black too whereas my icon is white !

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
    android:id="@+id/action_search"
    android:title="@string/menu_search"
    android:icon="@drawable/ic_search"
    app:actionViewClass="android.support.v7.widget.SearchView"
    app:showAsAction="always" />
</menu>

我想我的搜索查看是白色的。

I would like my SearchView be white.

推荐答案

在这里,在menu.xml文件添加,

Here in menu.xml add,

    <item
android:id="@+id/action_search"
android:icon="@drawable/icon"
android:title="Search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always"/>

在style.xml需要应用的风格像这样

in style.xml you need to apply style like this

    <style name="Theme.MyTheme" parent="Theme.AppCompat">
    <item name="searchViewStyle">@style/MySearchViewStyle</item>
</style>
<style name="MySearchViewStyle" parent="Widget.AppCompat.SearchView">
    <!-- Background for the search query section (e.g. EditText) -->
    <item name="queryBackground">...</item>
    <!-- Background for the actions section (e.g. voice, submit) -->
    <item name="submitBackground">...</item>
    <!-- Close button icon -->
    <item name="closeIcon">...</item>
    <!-- Search button icon -->
    <item name="searchIcon">...</item>
    <!-- Go/commit button icon -->
    <item name="goIcon">...</item>
    <!-- Voice search button icon -->
    <item name="voiceIcon">...</item>
    <!-- Commit icon shown in the query suggestion row -->
    <item name="commitIcon">...</item>
    <!-- Layout for query suggestion rows -->
    <item name="suggestionRowLayout">...</item>
</style>

终于在menifest文件:

and finally in menifest file:

    <application...
android:theme="@style/Theme.MyTheme" >

参考:
希望这有助于!

Ref: Android appcompact libraryHope this helped!

这篇关于主题在动作条搜索查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 02:54