是否有可能改变文字颜色上一个Android搜索查看?有可能、颜色、文字、Android

2023-09-12 04:13:50 作者:剪了长发断了情

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

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);