安卓改变searchview字体的颜色等

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/stimgo/article/details/81666989
这里要针对2种searchview进行操作,

通常的
- SearchView

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

v7包里的:

  • android.support.v7.widget.SearchView
SearchView.SearchAutoComplete textView = (SearchView.SearchAutoComplete)mSearchViewInclude.findViewById(R.id.search_src_text);
        textView.setTextColor(getResources().getColor(R.color.text_color_normal));
        textView.setHintTextColor(getResources().getColor(R.color.text_color_hint));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,13);

3.对于改变光标颜色

还是使用主题色改变吧,把colorAccent改为自己光标的颜色即可

  <item name="colorAccent">#27C084</item>

猜你喜欢

转载自blog.csdn.net/stimgo/article/details/81666989