我想更改 Xamarin.Android 中的搜索 TextView 颜色。到目前为止,我已经尝试过以下代码
searchView = this.Activity.FindViewById<Android.Support.V7.Widget.SearchView (Resource.Id.searchView);
searchView.SetOnQueryTextListener(this);
var textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
var textView = (searchView.FindViewById(textViewId) as TextView);
if (textView != null)
textView.SetTextColor(global::Android.Graphics.Color.White);
当我 try catch textView
时,我得到 NULL
在 textViewId
中,我得到的 View ID 类似于 126312727
谁能帮我解决上面的问题?
最佳答案
这是在应用程序外使用 Android.Support.V7.Widget.SearchView
var id = searchView.Context.Resources.GetIdentifier("search_src_text", "id", PackageName);
var searchEditText = searchView.FindViewById<EditText>(id);
searchEditText.SetTextColor(Color.Red);
关于c# - 更改 SearchView 文本颜色 Xamarin.Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51278158/