Xamarin-MaterialSearchView 2.0.0.1

dotnet add package Xamarin-MaterialSearchView --version 2.0.0.1                
NuGet\Install-Package Xamarin-MaterialSearchView -Version 2.0.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xamarin-MaterialSearchView" Version="2.0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xamarin-MaterialSearchView --version 2.0.0.1                
#r "nuget: Xamarin-MaterialSearchView, 2.0.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xamarin-MaterialSearchView as a Cake Addin
#addin nuget:?package=Xamarin-MaterialSearchView&version=2.0.0.1

// Install Xamarin-MaterialSearchView as a Cake Tool
#tool nuget:?package=Xamarin-MaterialSearchView&version=2.0.0.1                

sponsor me

alternate text is missing from this package README image

Basic example:

XML: Layout:

<?xml version="1.0" encoding="UTF-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/colorGray"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical">
   <include layout="@layout/search_container" />
</LinearLayout>

search_container.xml

<?xml version="1.0" encoding="UTF-8" ?>
<com.google.android.material.appbar.AppBarLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            app:theme="@style/ToolBarStyle"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary" />

        <com.miguelcatalan.materialsearchview.MaterialSearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>

</com.google.android.material.appbar.AppBarLayout>

Menu: menu_search.xml

<?xml version="1.0" encoding="UTF-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.domain.myApp.YourClassActivity">
    <item
        android:id="@+id/action_search"
        android:icon="@drawable/ic_action_action_search"
        android:orderInCategory="100"
        android:title="@string/search_title"
        app:showAsAction="always" />
</menu>

C#:

public partial class YourClassActivity : AppCompatActivity
{
    private MaterialSearchView SearchView;
    protected override void OnCreate(Bundle savedInstanceState)
    {

        SearchView = FindViewById<MaterialSearchView>(Resource.Id.search_view);

        SearchView.SetOnQueryTextListener(new MaterialSearchViewListener(this));

        //Optional to enable voice search
        //SearchView.SetVoiceSearch(true);        
    }

    public override bool OnCreateOptionsMenu(IMenu menu)
    {
        MenuInflater.Inflate(Resource.Menu.menu_search, menu);

        SearchView.SetMenuItem(menu.FindItem(Resource.Id.action_search));

        return true;
    }
}

public partial class YourClassActivity
{
    public class MaterialSearchViewListener : Java.Lang.Object, MaterialSearchView.IOnQueryTextListener
    {
        public bool OnQueryTextChange(string p0)
        {
            return true;
        }

        public bool OnQueryTextSubmit(string p0)
        {
            return true;
        }
    }
}

Follow me at:

LinkedIn YouTube Amazon Goodreads Instagram Cyber Prophets Sharing Your Stories
LinkedIn YouTube Amazon Goodreads Instagram RedCircle Podcast RedCircle Podcast
Product Compatible and additional computed target framework versions.
.NET net6.0-android was computed.  net7.0-android was computed.  net8.0-android was computed. 
MonoAndroid monoandroid is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0.1 683 8/12/2020
2.0.0 470 7/24/2020
1.0.0 834 6/26/2019

Upgraded to AndroidX.