Material Design Search Bar for Android

Overview

Material SearchBar Android

Material Design Search Bar for Android Android Arsenal


This beautiful and easy to use library will help to add Lollipop Material Design SearchView in your project.


See our Wiki

How to use

to include SearchBar to your project:

add this code to the the project level build.gradle file

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

add the dependency to the the app level build.gradle file

dependencies {
	implementation 'com.github.mancj:MaterialSearchBar:X.X.X'
}

then add SearchBar to your activity:

<com.mancj.materialsearchbar.MaterialSearchBar
    style="@style/MaterialSearchBarLight"
    app:mt_speechMode="true"
    app:mt_hint="Custom hint"
    app:mt_maxSuggestionsCount="10"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/searchBar" />

MaterialSearchBar has the following xml attributes:

Attribute Description
mt_speechMode if set to true, microphone icon will be displayed instead of search icon
mt_maxSuggestionsCount specifies the max number of search queries stored
mt_navIconEnabled set navigation icon enabled
mt_roundedSearchBarEnabled use capsule shaped searchbar on v21+ and revert to default on lower
mt_dividerColor set the colors of the suggestion and menu dividers
mt_searchBarColor set the main color of the searchbar
mt_menuIconDrawable set drawable of the menu icon
mt_searchIconDrawable set drawable of the search icon when speech mode is false
mt_speechIconDrawable set drawable of the speech icon when speech mode is true
mt_backIconDrawable set drawable of the back arrow icon
mt_clearIconDrawable set drawable of the clear icon
mt_navIconTint set tint color of nav/back animated icon
mt_menuIconTint set tint color of the menu icon
mt_searchIconTint set tint color search/speech icon
mt_backIconTint set tint color of the back arrow icon
mt_clearIconTint set tint color of the clear icon
mt_navIconUseTint should the animated nav icon use tint color
mt_menuIconUseTint should the menu icon use the tint color
mt_searchIconUseTint should the search/speech icon use the tint color
mt_backIconUseTint should the back icon use the tint color
mt_clearIconUseTint should the clear icon use the tint color
mt_hint set the text of the hint when the searchbar is focused and search query is empty
mt_placeholder set the placeholder text when the MaterialSearchBar is not focused
mt_textColor set text color
mt_hintColor set hint color
mt_placeholderColor set placeholder color
mt_textCursorTint set text cursors tint
mt_highlightedTextColor set the text highlight tint color

public methods:

  • addTextChangeListener(TextWatcher textWatcher)
  • clearSuggestions()
  • closeSearch()
  • openSearch()
  • getLastSuggestions()
  • getMenu()
  • getText()
  • hideSuggestionList()
  • inflateMenu(int menuResource)
  • inflateMenu(int menuResource, int icon)
  • isSearchOpened()
  • isSpeechModeEnabled()
  • isSuggestionsVisible()
  • setArrowIcon(int arrowIconResId)
  • setArrowIconTint(int arrowIconTint)
  • setCardViewElevation(int elevation)
  • setClearIcon(int clearIconResId)
  • setClearIconTint(int clearIconTint)
  • setCustomSuggestionAdapter(SuggestionsAdapter suggestionAdapter)
  • setDividerColor(int dividerColor)
  • setHint(CharSequence hintText)
  • setIconRippleStyle(boolean borderlessRippleEnabled)
  • setLastSuggestions(List suggestions)
  • setMaxSuggestionCount(int maxSuggestionsCount)
  • setMenuDividerEnabled(boolean menuDividerEnabled)
  • setMenuIcon(int menuIconResId)
  • setMenuIconTint(int menuIconTint)
  • setNavButtonEnabled(boolean navButtonEnabled)
  • setNavIconTint(int navIconTint)
  • setOnSearchActionListener(OnSearchActionListener onSearchActionListener)
  • setPlaceHolder(CharSequence placeholder)
  • setPlaceHolderColor(int placeholderColor)
  • setRoundedSearchBarEnabled(boolean roundedSearchBarEnabled)
  • setSearchIcon(int searchIconResId)
  • setSearchIconTint(int searchIconTint)
  • setSpeechModeEnabled(boolean speechMode)
  • setSuggestionsClickListener(SuggestionsAdapter.OnItemViewClickListener listener)
  • setText(String text)
  • setTextColor(int textColor)
  • setTextHighlightColor(int highlightedTextColor)
  • setTextHintColor(int hintColor)
  • showSuggestions()
  • updateLastSuggestions(List suggestions)

Styling Material SearchBar

Custom Style - styles.xml Create a custom style and use one of the provided styles as the parent.

Provided Styles are: MaterialSearchBarLight and MaterialSearchBarDark

Example:
<style name="MyCustomTheme" parent="MaterialSearchBarLight">
     <item name="mt_searchBarColor">@color/searchBarPrimaryColor</item>
            <item name="mt_dividerColor">@color/searchBarDividerColor</item>
            <item name="mt_navIconTint">@color/searchBarNavIconTintColor</item>
            <item name="mt_searchIconTint">@color/searchBarSearchIconTintColor</item>
            <item name="mt_clearIconTint">@color/searchBarClearIconTintColor</item>
            <item name="mt_menuIconTint">@color/searchBarMenuIconTintColor</item>
            <item name="mt_backIconTint">@color/searchBarBackIconTintColor</item>
            <item name="mt_textCursorTint">@color/searchBarCursorColor</item>
            <item name="mt_textColor">@color/searchBarTextColor</item>
            <item name="mt_hintColor">@color/searchBarHintColor</item>
            <item name="mt_placeholderColor">@color/searchBarPlaceholderColor</item>
            <item name="mt_highlightedTextColor">@color/searchBarTextHighlightColor</item>
</style>

OR

Custom Colors - colors.xml Simply set/change these colors(or some) and you have your custom style.

    //Material SearchBar Light Theme Colors
        <color name="searchBarIconColor">#3a3a3a</color>
        //Base
        <color name="searchBarPrimaryColor">#FFFFFF</color>
        <color name="searchBarCursorColor">#8000a1ff</color>
        <color name="searchBarDividerColor">#1F000000</color>
    
        //Icons
        <color name="searchBarNavIconTintColor">@color/searchBarIconColor</color>
        <color name="searchBarMenuIconTintColor">@color/searchBarIconColor</color>
        <color name="searchBarSearchIconTintColor">@color/searchBarIconColor</color>
        <color name="searchBarClearIconTintColor">@color/searchBarIconColor</color>
        <color name="searchBarBackIconTintColor">@color/searchBarIconColor</color>
    
        //Text
        <color name="searchBarTextColor">#DE000000</color>
        <color name="searchBarHintColor">#42000000</color>
        <color name="searchBarPlaceholderColor">#8A000000</color>
        <color name="searchBarTextHighlightColor">#8000a1ff</color>
    
        //Base
        <color name="searchBarPrimaryColorDark">#303030</color>
        <color name="searchBarDividerColorDark">#1FFFFFFF</color>
    
        //Material SearchBar Dark Theme Colors
        <color name="searchBarIconColorDark">#00a1ff</color>
        //Icons
        <color name="searchBarNavIconTintColorDark">@color/searchBarIconColorDark</color>
        <color name="searchBarMenuIconTintColorDark">@color/searchBarIconColorDark</color>
        <color name="searchBarSearchIconTintColorDark">@color/searchBarIconColorDark</color>
        <color name="searchBarClearIconTintColorDark">@color/searchBarIconColorDark</color>
        <color name="searchBarBackIconTintColorDark">@color/searchBarIconColorDark</color>
    
        //Text
        <color name="searchBarTextColorDark">#DEFFFFFF</color>
        <color name="searchBarHintColorDark">#42FFFFFF</color>
        <color name="searchBarPlaceholderColorDark">#8AFFFFFF</color>
        <color name="searchBarTextHighlightColorDark">#BF00a1ff</color>

To save search queries when the activity is destroyed, use the method searchBar.getLastSuggestions() and then, to restore them use searchBar.setLastSuggestions(List<String>); as shown in the example below

Example

Here is a simple example of using MaterialSearchBar

private List<String> lastSearches;
private MaterialSearchBar searchBar;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    searchBar = (MaterialSearchBar) findViewById(R.id.searchBar);
    searchBar.setHint("Custom hint");
    searchBar.setSpeechMode(true);
    //enable searchbar callbacks
    searchBar.setOnSearchActionListener(this);
    //restore last queries from disk
    lastSearches = loadSearchSuggestionFromDisk();
    searchBar.setLastSuggestions(list);
    //Inflate menu and setup OnMenuItemClickListener
    searchBar.inflateMenu(R.menu.main);
    searchBar.getMenu().setOnMenuItemClickListener(this);
}

@Override
protected void onDestroy() {
    super.onDestroy();
    //save last queries to disk
    saveSearchSuggestionToDisk(searchBar.getLastSuggestions());
}

@Override
public void onSearchStateChanged(boolean enabled) {
    String s = enabled ? "enabled" : "disabled";
    Toast.makeText(MainActivity.this, "Search " + s, Toast.LENGTH_SHORT).show();
}

@Override
public void onSearchConfirmed(CharSequence text) {
    startSearch(text.toString(), true, null, true);
}

@Override
public void onButtonClicked(int buttonCode) {
    switch (buttonCode){
        case MaterialSearchBar.BUTTON_NAVIGATION:
            drawer.openDrawer(Gravity.LEFT);
            break;
        case MaterialSearchBar.BUTTON_SPEECH:
            openVoiceRecognizer();
    }
}

More Examples

Comments
  • Once the number of items in the CustomSuggestionAdapter decreases, the list view shrinks.

    Once the number of items in the CustomSuggestionAdapter decreases, the list view shrinks.

    Once the number of items in the CustomSuggestionAdapter decreases, the list view shrinks. Even if i add the items into the list agiain. It never increases.

    Steps to reproduce :

    1. Try to initialize the CustomSuggestionAdapter with zero items.
    2. Now increase the number of items in the CustomSuggestionAdapter during runtime.
    3. We can never see the list view of suggestions coming up.

    I was trying to do a predictive search by calling a webservice. The number of items increases and decreases based on the search key.

    "I have done some workaround to fix the issue for me for now", but its a temporary fix.

    My further steps would be to combine recent searches when user hasn't typed anything, and once the user starts typing i will call the webservice and get the results and show in this suggestions area. i will write an article on the Material Search bar once I complete my implementation.

    Thanks, Adarsh

    opened by c4adarsh 13
  • No field mCursorDrawableRes in class Landroid/widget/TextView

    No field mCursorDrawableRes in class Landroid/widget/TextView

    W/System.err: java.lang.NoSuchFieldException: No field mCursorDrawableRes in class Landroid/widget/TextView; (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar!classes3.dex) at java.lang.Class.getDeclaredField(Native Method) at com.mancj.materialsearchbar.MaterialSearchBar.setupCursorColor(MaterialSearchBar.java:317) at com.mancj.materialsearchbar.MaterialSearchBar.setupSearchEditText(MaterialSearchBar.java:300) at com.mancj.materialsearchbar.MaterialSearchBar.postSetup(MaterialSearchBar.java:265) at com.mancj.materialsearchbar.MaterialSearchBar.init(MaterialSearchBar.java:207) at com.mancj.materialsearchbar.MaterialSearchBar.(MaterialSearchBar.java:117) W/System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at android.view.LayoutInflater.createView(LayoutInflater.java:854) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084) at android.view.LayoutInflater.inflate(LayoutInflater.java:682) at android.view.LayoutInflater.inflate(LayoutInflater.java:534) at android.view.LayoutInflater.inflate(LayoutInflater.java:481) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) at com.beingknow.eatit2020.Activities.FoodListActivity.onCreate(FoodListActivity.java:54) at android.app.Activity.performCreate(Activity.java:7802) at android.app.Activity.performCreate(Activity.java:7791) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299) W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

    opened by furqanyasin 7
  • cannot use search and history suggestion fiture

    cannot use search and history suggestion fiture

    package com.mancj.example;

    import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.view.Gravity; import android.view.View; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem;

    import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import java.util.ArrayList; import java.util.Arrays; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory;

    import com.mancj.materialsearchbar.MaterialSearchBar;

    public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, MaterialSearchBar.OnSearchActionListener { MaterialSearchBar searchBar; private DrawerLayout drawer; private RecyclerView recyclerView; private ArrayList data; private DataAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initViews();
    
        drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        searchBar = (MaterialSearchBar) findViewById(R.id.searchBar);
        searchBar.setOnSearchActionListener(this);
        searchBar.inflateMenu(R.menu.main);
    }
    
    private void initViews(){
        recyclerView = (RecyclerView)findViewById(R.id.card_recycler_view);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setHasFixedSize(true);
        loadJSON();
    }
    
    private void loadJSON(){
        OkHttpClient.Builder client = new OkHttpClient.Builder();
        client.readTimeout(60, TimeUnit.SECONDS);
        client.connectTimeout(60, TimeUnit.SECONDS);
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://192.168.1.16")
                .client(client.build())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        RequestInterface request = retrofit.create(RequestInterface.class);
        Call<JSONResponse> call = request.getJSON();
        call.enqueue(new Callback<JSONResponse>() {
            @Override
    
            public void onResponse(Call<JSONResponse> call, Response<JSONResponse> response) {
                JSONResponse jsonResponse = response.body();
                data = new ArrayList<>(Arrays.asList(jsonResponse.getPerson()));
                adapter = new DataAdapter(data);
                recyclerView.setAdapter(adapter);
            }
    
            @Override
            public void onFailure(Call<JSONResponse> call, Throwable t) {
                Log.d("Error",t.getMessage());
            }
        });
    }
    
    
    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
    
        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }
    
        return super.onOptionsItemSelected(item);
    }
    
    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();
    
        if (id == R.id.nav_camera) {
            // Handle the camera action
        } else if (id == R.id.nav_gallery) {
    
        } else if (id == R.id.nav_slideshow) {
    
        } else if (id == R.id.nav_manage) {
    
        } else if (id == R.id.nav_share) {
    
        } else if (id == R.id.nav_send) {
    
        }
    
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
    
    @Override
    public void onSearchStateChanged(boolean enabled) {
    
    }
    
    @Override
    public void onSearchConfirmed(CharSequence text) {
    
    }
    
    @Override
    public void onButtonClicked(int buttonCode) {
        switch (buttonCode){
            case MaterialSearchBar.BUTTON_NAVIGATION:
                drawer.openDrawer(Gravity.LEFT);
                break;
            case MaterialSearchBar.BUTTON_SPEECH:
        }
    }
    

    }

    opened by MuhSalmaNabila 5
  • Failed To Resolve com.github.mancj:MaterialSearchBar:0.7.6

    Failed To Resolve com.github.mancj:MaterialSearchBar:0.7.6

    i have added this code to the project level build.gradle file still facing the issue . allprojects { repositories { ... maven { url "https://jitpack.io" } } }

    opened by ghost 4
  • Resource not found exception

    Resource not found exception

    I am getting exception when i tried to change text color using setTextColor() method 01-03 16:46:03.757 15355-15355/com.onlineshopping.deals.browser.shopping E/AndroidRuntime: FATAL EXCEPTION: main Process: com.onlineshopping.deals.browser.shopping, PID: 15355 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.onlineshopping.deals.browser.shopping/nudimelabs.com.browser.NavigationActivity}: android.content.res.Resources$NotFoundException: Resource ID #0xff000000 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394) at android.app.ActivityThread.access$800(ActivityThread.java:154) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5276) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703) Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xff000000 at android.content.res.Resources.getValue(Resources.java:1284) at android.content.res.MiuiResources.getValue(MiuiResources.java:145) at android.content.res.Resources.getColor(Resources.java:938) at android.support.v4.content.ContextCompat.getColor(ContextCompat.java:434) at com.mancj.materialsearchbar.MaterialSearchBar.setupTextColors(MaterialSearchBar.java:179) at com.mancj.materialsearchbar.MaterialSearchBar.setTextColor(MaterialSearchBar.java:356) at nudimelabs.com.browser.NavigationActivity.onCreate(NavigationActivity.java:84) at android.app.Activity.performCreate(Activity.java:6041) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2285) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)  at android.app.ActivityThread.access$800(ActivityThread.java:154)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5276)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703) 

    Here is my code snippet MaterialSearchBar searchBar= (MaterialSearchBar) findViewById(R.id.searchBar); searchBar.setHint("Search..."); searchBar.setTextColor(Color.BLACK); searchBar.setOnSearchActionListener(this); I am using com.github.mancj:MaterialSearchBar:0.3.5 version

    opened by shubhdo 4
  • [Feature request] Search on typing

    [Feature request] Search on typing

    For now, the search action can only be trigger manually. I'd like trigger the search after some delay during typing. Unfortunately, with current implementation, I cannot call the listener from my subclass.

    opened by letientai299 4
  • (Question) How change PopupMenu Style!

    (Question) How change PopupMenu Style!

    Hi there, I've tried to change SearchBar Menu style by using style, but does not work! I'm using search bar in fragment, my parent activity style is like this:

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    
        <item name="android:itemTextAppearance">@style/itemTextStyle.AppTheme</item>
    
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
        <item name="android:textAppearanceLargePopupMenu">@style/PopupMenuTextAppearanceLarge</item>
        <item name="android:textAppearanceSmallPopupMenu">@style/PopupMenuTextAppearanceSmall</item>
    
    </style>
    
    <style name="itemTextStyle.AppTheme" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
        <item name="android:textColor">@color/iconColor</item>
        <item name="android:textSize">@dimen/h3</item>
    </style>
    
    <!-- Popup Menu Style -->
    <style name="PopupMenu" parent="@style/Widget.AppCompat.Light.PopupMenu">
        <item name="android:popupBackground">@android:color/white</item>
        <item name="android:textColor">@color/iconColor</item>
        <item name="android:textSize">@dimen/h3</item>
    </style>
    <style name="PopupMenuTextAppearanceSmall" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small">
        <item name="android:textColor">@color/iconColor</item>
        <item name="android:textSize">@dimen/h3</item>
    </style>
    <style name="PopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large">
        <item name="android:textColor">@color/iconColor</item>
        <item name="android:textSize">@dimen/h0</item>
    </style>
    <!-- Popup Menu Style -->
    

    How can do that?

    opened by IRMobydick 3
  • Failed to resolve: com.github.mancj:MaterialSearchBar:0.7.1

    Failed to resolve: com.github.mancj:MaterialSearchBar:0.7.1

    I get this error when syncing the gradle after adding compile 'com.github.mancj:MaterialSearchBar:0.7.1' to my gradle. What's the reason for this?

    Message:

    Failed to resolve: com.github.mancj:MaterialSearchBar:0.7.1
    
    opened by dinukapj 2
  • EditText cursor color

    EditText cursor color

    Currently the cursor for the EditText box for me is defaulting to white due to our apps theme but I want to set the color of the cursor in the search bar specifically so it can actually appear clearly over its white background. Any chance of getting access to the textCursorDrawable() method or something similar to the Hint and Text color methods?

    opened by Snowda 2
  • How to update the suggestions list while typing in the searchbar?

    How to update the suggestions list while typing in the searchbar?

    I can't figure out how to update the suggestions list in the searchbar when typing in it. Could you help me please?

    I have a TextWatcher on the searchbar and when the user types in the text the database is queried in the background, in AsyncTask, and then creates the list of suggestions. Then, it executes the method of my Activity which sets the suggestions to the searchbox.

    Here is what that method does:

    public void updateSearch(List<Suggestion> suggestions) {
            customSuggestionsAdapter.setSuggestions(suggestions);
            searchBar.setCustomSuggestionAdapter(customSuggestionsAdapter);
    }
    

    But nothing happens in the searchbox. That is, the suggestion list does not appear. If I press the back button on the searchbar and disable the search and then enable it again, that is, I press on the search bar, then the suggestion list appears, so I gather it was actually set to the searhbar but did not refresh on the screen. But what should I do to make it appear and change while typing in the searchbox? As a stupid hack I can get it around by automatic disable and enable of the seachBar right after I set the suggestion adapter, but that update doesn't look good visually, and I suppose I just missed something simple.

    opened by al-t 2
  • Click of the Custom Suggestion Adapter doesn't return on the callback setSuggstionsClickListener

    Click of the Custom Suggestion Adapter doesn't return on the callback setSuggstionsClickListener

    Your Material Search bar implementation is awesome, but there is slight problem when i try to use it.

    When I give the customSuggestionAdapter, setSuggstionsClickListener is not working. Can you please change the implementation to give call back to the click listener.

    MaterialSearchBar.java

    "if (adapter instanceof DefaultSuggestionsAdapter) ((DefaultSuggestionsAdapter) adapter).setListener(this);"

    OR Can you please give methods to hide the image and the cross mark in the suggestions.

    I am showing a predictive search after hitting a server. So the clock image and the cross image in the view is not relevant for my implementation.

    Thanks, Adarsh

    opened by c4adarsh 2
  • Cannot be cast to java.lang.String with custom suggestions adapter

    Cannot be cast to java.lang.String with custom suggestions adapter

    Hi, we use a custom suggestion adapter as in the example provided. Everything goes well most of the times, but we got some Cannot be cast to java.lang.String exceptions in production like the following:

    Fatal Exception: java.lang.ClassCastException
      com.test.card.common.datamodel.catalog.Restaurants cannot be cast to java.lang.String
      com.mancj.materialsearchbar.adapter.DefaultSuggestionsAdapter.onBindSuggestionHolder (DefaultSuggestionsAdapter.java:17)
      com.mancj.materialsearchbar.adapter.SuggestionsAdapter.onBindViewHolder (SuggestionsAdapter.java:92)
      androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder (RecyclerView.java:7254)
      androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder (RecyclerView.java:7337)
      androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline (RecyclerView.java:6194)
      androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:6460)
      androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6300)
      androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6296)
      androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2330)
      androidx.recyclerview.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1631)
      androidx.recyclerview.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1591)
      androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:668)
      ....
    

    From the stack trace we see that the RecyclerView onBindViewHolder is referring to the DefaultSuggestionsAdapter class, not to our custom suggestion adapter we have set through the setCustomSuggestionAdapter as I was expecting.

    Any idea on how to fix it? As I said the searchBar works correctly in many cases, but from some users we've got this exception. Should we refer to the custom suggestion adapter also from the layout xml of the searchbar? How?

    opened by gfalasca 1
  • Incompatible with Gradle 8.0

    Incompatible with Gradle 8.0

    Hi, I'm trying to implement this to my project but I'm getting this

    image

    Android Gradle Plugin Version: 7.0.3 Gradle Version: 7.0.2

    Any idea how it will be worked with the latest version of gradle?

    opened by babis91 0
  • Font Family

    Font Family

    HI!

    I implemented this in my project and everything is working fine. But I am not able to add the font family of the text or the hint Text. Is there any option to add the font family, or is it not in the library?

    opened by prchchouksey 0
  • Suggestion Text Color

    Suggestion Text Color

    Hey I am trying to change the color of the text of the suggestions but I cant find the way to do it. I want to make the text color of suggestions white. I could use some help! Thanks image image

    opened by vision4shops 2
Releases(0.8.5)
Owner
Mansour
Mansour
Android Floating Label

FloatingLabel FloatingLabel Allows you to create a blow kind of EditText. To explain the concept well I have taken below image from http://dribbble.co

Hardik Trivedi 290 Nov 30, 2022
🔑A customizable EditText for Android with a switchable eye which shows or hides the password

Sweet Password A customizable password component for Android Setup Gradle repositories { jCenter() } dependencies { compile 'mx.jesusmartinoz

Jesús Alberto Martínez Mendoza 19 Apr 11, 2022
CuteToast is an Material Design Custom Toast for Android | Custom Material Design Toast

CuteToast is an Android Custom Toast library that could be used instead of Default Toast. It does everything as Toast but with some extra spice.

K M Rejowan Ahmmed 12 Dec 17, 2022
Material Design text field that comes in a box, based on (OLD) Google Material Design guidelines.

TextFieldBoxes A new Material Design text field that comes in a box, based on Google Material Design guidelines. ???? 中文看这里 UPDATE NOTICE 1.4.5 Releas

Mark Wang 769 Jan 7, 2023
Android Search View based on Material design guidelines.

Android SearchView based on Material Design guidelines. The MaterialSearchView will overlay a Toolbar or ActionBar as well as display a ListView for the user to show suggested or recent searches.

Maurício C. P. Pessoa 1.1k Nov 11, 2022
Material Design Search View Layout, now implemented in Google Maps, Dialer, etc

THIS PROJECT IS DEPRECATED Component is not maintained anymore. Implementation of Lollipop+ Dialer and Google Maps. DEMO Add in View Add to your layou

Sahil Dave 1.1k Dec 22, 2022
Android app to search for covid vaccine slots, turn on background search & get notifications when slots are available

CowinNotifier Android app to search for covid vaccine slots, turn on background search & get notifications when slots are available Glipmse of the App

Ujjwal Kumar Maharana 3 Dec 29, 2022
Image-search - An Image search android app with offline support

image-search Image search app built using bing image search API via paging 3. Fe

Suraj Vaishnav 3 Feb 17, 2022
A simple Cat Search app, performed the search by cat breed name, using MVVM clean Architecture.

CatSearchApp A simple Cat Search app, performed the search by cat breed name, using MVVM clean Architecture. The App is using the The Cat Api for sear

Mansingh Bhati 2 Oct 20, 2022
Anime-Info-Search-Jikan - Search Information about Anime

Anime-Info-Search-Jikan Search Information about Anime. Home Page Information Pa

null 3 Nov 13, 2022
[] Action bar implementation which uses the native action bar on Android 4.0+ and a custom implementation on pre-4.0 through a single API and theme.

DEPRECATED ActionBarSherlock is deprecated. No more development will be taking place. For an up-to-date action bar backport use AppCompat. Thanks for

Jake Wharton 7.1k Dec 24, 2022
IOSProgressBar is a progress-bar lib for android. And the progress-bar looks like iOS system style

IOSProgressBar is a progress-bar lib for android. And the progress-bar looks like iOS system style

heyangyang 6 Aug 25, 2022
SystemUiController - Android Ui color controller (status bar, navigation bar)

SystemUiController Android system ui color controller (status bar, navigation bar) Download implementation "land.sungbin:systemuicontroller:${version}

Ji Sungbin 8 Dec 3, 2022
Bottom-App-Bar-with-Bottom-Navigation-in-Jetpack-compose-Android - Bottom App Bar with Bottom Navigation in Jetpack compose

Bottom-App-Bar-with-Bottom-Navigation-in-Jetpack-compose-Android This is simple

Shruti Patel 1 Jul 11, 2022
This directory contains the model files (protos) for the Bar ServiceThis directory contains the model files (protos) for the Bar Service

This directory contains the model files (protos) for the Bar ServiceThis directory contains the model files (protos) for the Bar Service

Logesh Dinakaran 0 Nov 22, 2021
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022