我需要在我的ActionBar
中更改我的SearchView
的样式。特别是如果可能,我需要更改文本提示颜色和SearchView
图标。我怎样才能在XML中完成这项工作(甚至可以用XML)?Android如何在Actionbar中设置SearchView风格?
如果这是不可能的,我怎样才能轻松地重新创建与自定义视图相似的行为? SearchView
的关闭/展开行为对我来说特别有用。
我需要在我的ActionBar
中更改我的SearchView
的样式。特别是如果可能,我需要更改文本提示颜色和SearchView
图标。我怎样才能在XML中完成这项工作(甚至可以用XML)?Android如何在Actionbar中设置SearchView风格?
如果这是不可能的,我怎样才能轻松地重新创建与自定义视图相似的行为? SearchView
的关闭/展开行为对我来说特别有用。
看起来您可能需要为您的搜索操作提供自定义布局。我一直无法找到任何有关修改默认SearchView的文档。但是这确实允许关闭/展开行为。
http://developer.android.com/guide/topics/ui/actionbar.html#ActionView
相关问题:
你有没有尝试过这样的事情(有ActionBarSherlock):
AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchText.setHintTextColor(getResources().getColor(R.color.white));
searchText.setTextColor(getResources().getColor(R.color.white));
它适用于我。
您正在使用ActionbarSherlock。 – wangqi060934 2013-05-24 12:44:52
这适用于ActionBarSherlock和android:minSdkVersion =“8”。谢谢! – Munchies 2013-05-28 15:49:20
应该是被接受的答案。谢谢! – 2014-03-13 09:28:10
您需要创建一个新主题并在清单文件中使用它。
<style name="Theme.Test" parent="@style/Theme.AppCompat.Light">
<item name="searchViewAutoCompleteTextView">@style/Theme.Test.SearchField</item>
</style>
<!-- Search edit text -->
<style name="Theme.Test.SearchField" parent="@style/Widget.AppCompat.Light.AutoCompleteTextView">
<item name="android:textColor">@color/white</item>
<item name="android:textColorHint">@color/white</item>
</style>
它对我来说工作得很好。
正确的答案是用您自己的自定义样式重载操作栏小部件样式。对于黑暗行动起来吧全息光,把这个在自己的样式文件,如res/values/styles_mytheme.xml
:
<style name="Theme.MyTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarWidgetTheme">@style/Theme.MyTheme.Widget</item>
<!-- your other custom styles -->
</style>
<style name="Theme.MyTheme.Widget" parent="@android:style/Theme.Holo">
<item name="android:textColorHint">@android:color/white</item>
<!-- your other custom widget styles -->
</style>
确保您的应用程序使用主题自定义主题为enter link description here
说明你有没有发现这个问题的解决方案? Plase别忘了在这里通知我们 - 或者如果没有说明你的问题,请。 :-) – 2013-01-07 09:31:53
我设法修改提示颜色像这样:http://stackoverflow.com/questions/17791388/changing-action-bar-searchview-hint-text-color – Soflete 2013-07-28 23:46:34