是否有可能改变文字颜色上一个Android搜索查看? [英] Is it possible to change the textcolor on an Android SearchView?

查看:110
本文介绍了是否有可能改变文字颜色上一个Android搜索查看?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在搜索查看元素没有任何属性改变文字颜色。默认文本颜色为黑色,不上我们的深色背景的工作。有没有办法来改变文本的颜色,而不诉诸黑客?

The SearchView element doesn't have any properties for changing the text color. The default text color is black and doesn't work on our dark background. Is there a way to change the color of the text without resorting to hacks?

我发现有关更改文字大小这类似的问题,但到目前为止,它没有任何答案: 如何设置搜索查看TEXTSIZE?

I found this similar question related to changing the text size, but so far, it doesn't have any answers: How to set SearchView TextSize?

推荐答案

尝试是这样的: 你会得到一个处理从SDK TextView的,然后改变它,因为他们不公开它公开。

Try something like this : You would get a handle to the textview from the sdk and then change it since they don't expose it publicly.

int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);
textView.setTextColor(Color.WHITE);

这篇关于是否有可能改变文字颜色上一个Android搜索查看?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆