我找不到任何关于Xamarin android处理SearchView的文章。
下面的searchView将提供黑色背景和白色textColor
1)我需要将背景颜色设置为白色,将textColor设置为白色。 2)如果用户决定不使用搜索,键盘就不会消失。 单击searchView后如何关闭键盘?
谢谢
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:orientation="vertical"> <SearchView android:minWidth="25px" android:minHeight="25px" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:id="@+id/sv" /> <ListView android:minWidth="25px" android:minHeight="25px" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/merchantListView" /> </LinearLayout>I could not find any article on Xamarin android handling SearchView.
The searchView below will provide a black background and white textColor
1) I need to set the background color white and textColor white. 2) The keyboard wont go away if user decided not to use search. How to dismiss the keyboard after clicking the searchView?
Thanks
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:orientation="vertical"> <SearchView android:minWidth="25px" android:minHeight="25px" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:id="@+id/sv" /> <ListView android:minWidth="25px" android:minHeight="25px" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/merchantListView" /> </LinearLayout>最满意答案
使用以下代码将文本颜色设置为黑色
SearchView sv = FindViewById<SearchView>(Resource.Id.sv); int id = sv.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); TextView tv = (TextView)sv.FindViewById(id); tv.SetTextColor(Android.Graphics.Color.Black);您可以单击键盘上的搜索玻璃图标以关闭它,或者在需要关闭SearchView的焦点时设置sv.ClearFoucs() 。
Use the below code to set text color to black
SearchView sv = FindViewById<SearchView>(Resource.Id.sv); int id = sv.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); TextView tv = (TextView)sv.FindViewById(id); tv.SetTextColor(Android.Graphics.Color.Black);You can click on the search glass icon in keyboard to dismiss it or set sv.ClearFoucs() whenever you need to dismiss focus for the SearchView.
更多推荐
发布评论