protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); MySearchBar Content = sender as MySearchBar; this.Control.BackgroundImage = new UIKit.UIImage(); this.Control.Layer.BorderWidth = 0; this.Control.Layer.BorderColor = Color.Red.ToCGColor(); this.Control.Layer.ShadowOpacity = 0; }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); if (Control != null) { mySearchBar = e.NewElement as MySearchBar; var searchView = Control; searchView.Iconified = true; searchView.SetIconifiedByDefault(false); // (Resource.Id.search_mag_icon); is wrong / Xammie bug int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null); var icon = searchView.FindViewById(searchIconId); (icon as ImageView).SetImageResource(Resource.Drawable.abc_ic_ab_back_material); (icon as ImageView).SetColorFilter(Android.Graphics.Color.White); icon.Click += Icon_Click; } }
public override void ViewDidLoad() { base.ViewDidLoad(); TableView.Source = new SearchDataSource(DBMgr.Instance); View.BackgroundColor = Utils.getThemeColor(); this.Title = "Search"; TableView.ReloadData(); MySearchBar.BecomeFirstResponder(); MySearchBar.SearchButtonClicked += (sender, e) => { MySearchBar.ResignFirstResponder(); string text = MySearchBar.Text.Trim(); performSearch(text); }; MySearchBar.TextChanged += (sender, e) => { string text = e.SearchText; performSearch(text); }; // TableView.RegisterNibForCellReuse(SummaryTableViewCell.Nib, "ITEM_CELL"); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); if (e.NewElement != null) { MySearchBar Content = e.NewElement as MySearchBar; this.Control.SetBackgroundResource(Resource.Drawable.back_for_search); Android.Widget.SearchView searchView = (base.Control as Android.Widget.SearchView); int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View); frameView.SetBackgroundColor(Xamarin.Forms.Color.Transparent.ToAndroid()); // frameView.SetBackgroundResource(Resource.Drawable.textfield_searchview_holo_light); // Get native control (background set in shared code, but can use SetBackgroundColor here) searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal); // Access search textview within control int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); EditText textView = (searchView.FindViewById(textViewId) as EditText); // textView.SetBackgroundResource(Resource.Drawable.textfield_searchview_holo_light); // Set custom colors // textView.SetBackgroundColor( Android.Graphics.Color.White ); // textView.SetTextColor( G.Color.Rgb( 32, 32, 32 ) ); // textView.SetHintTextColor( G.Color.Rgb( 128, 128, 128 ) ); // // Customize frame color // int frameId = searchView.Context.Resources.GetIdentifier( "android:id/search_plate", null, null ); // Android.Views.View frameView = (searchView.FindViewById( frameId ) as Android.Views.View); // frameView.SetBackgroundColor( G.Color.Rgb( 96, 96, 96 ) ); // SetBackgr (this.Control); } }