所以,我使用searchView小部件编写了这个menu.xml:
<item android:id="@+id/action_search"
android:title="@string/action_search"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView" />
我试图在样式xml中设置样式(queryHint和图标属性):
<resources>
<!-- Base App Theme -->
<style name="AppTheme" parent="CustomTheme.Base" />
<style name="CustomTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="searchViewStyle">@style/CustomTheme.Base.SearchView</item>
</style>
<style name="CustomTheme.Base.SearchView" parent="Widget.AppCompat.SearchView">
<item name="searchIcon">@drawable/ic_search</item>
<item name="queryHint">@string/search_hint</item>
</style>
</resources>
结果是一个没有图标且没有个性化查询的searchView小部件... 我一直在搜索,我最终尝试了这个solution,但每当我尝试使用我的app命名空间为searchIcon或queryHint项添加前缀时,我就会在启动时遇到此错误:
Error:(26, 21) No resource found that matches the given name: attr 'app:searchIcon'.
Error:(26, 21) No resource found that matches the given name: attr 'app:queryHint '.