风格化的搜索查看小工具使用支持库V21小工具、风格

2023-09-05 06:20:41 作者:我的幸福无法靠岸

我想使用的样式新AppCompat V21的搜索查看窗口小部件,但我面临的一些问题。不管是什么布局我的suggestionRowLayout属性设置,它什么都没有。该搜索查看的建议下拉列表中仍然以同样的方式。

I'm trying to style the SearchView widget using the new AppCompat v21, but I'm facing some problems. No matter what layout I set on "suggestionRowLayout" attribute, it does nothing at all. The suggestion dropdown list of the SearchView remains the same way.

这是我遇到的其他问题是当强调色是同色的原色,在搜索查看,无法分辨哪里是尖。你知道我怎么可以改变口音的颜色在搜索查看,只在那里适用?我发现,播放音乐有同样的问题。

Other problem that I'm having is when the "accent color" is the same color as the "primary color", in the searchview is impossible to distinguish where is the caret. Do you know how can I change the accent color in the SearchView to only be applied there? I've found that Play Music has the same problem.

我下面从Android开发者博客指南:

I'm following the guide from Android Developers blog:

http://android-developers.blogspot.com.es/2014/10/appcompat-v21-material-design-for-$p$p.html

推荐答案

据我所看到的检索属性时搜索查看 suggestionRowLayout 资源价值出现搜索查看源代码对于搜索查看和方法 getSuggestionRowLayout()。另外V7库SuggestionAdapter的实施充气 abc_search_dropdown_item_icons_2line

According to what I have seen in the SearchView source suggestionRowLayout resource value in SearchView occurs when retrieving the attributes for the SearchView and in the method getSuggestionRowLayout(). On the other hand the implementation of SuggestionAdapter of v7 library is inflating abc_search_dropdown_item_icons_2line.

理念的一种解决方法:

尝试引用不同的布局与 refs.xml 帮助。请务必保持相同的ID为意见在 abc_search_dropdown_item_icons_2line

Try referencing different layout with help of refs.xml. Make sure you keep same ids for views as in abc_search_dropdown_item_icons_2line

 <item type="layout" name="abc_search_dropdown_item_icons_2line">@layout/my_suggestion_row</item>