31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using Android.Content;
|
|
using Android.Widget;
|
|
using Xamarin.Forms;
|
|
using Xamarin.Forms.Platform.Android;
|
|
|
|
[assembly: ExportRenderer(typeof(SearchBar), typeof(Gallery.Droid.Renderers.SearchBarRenderer))]
|
|
namespace Gallery.Droid.Renderers
|
|
{
|
|
public class SearchBarRenderer : Xamarin.Forms.Platform.Android.SearchBarRenderer
|
|
{
|
|
public SearchBarRenderer(Context context) : base(context)
|
|
{
|
|
}
|
|
|
|
protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)
|
|
{
|
|
base.OnElementChanged(e);
|
|
|
|
if (e.NewElement != null && Control is SearchView searchView)
|
|
{
|
|
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.ic_search);
|
|
}
|
|
}
|
|
}
|
|
}
|