I'm using arimorty/floatingsearchview library for searchbar and it is working fine but now I want to a notification icon with a red circle/badge without count, but cannot find a way to make it.
in activity:
<com.arlib.floatingsearchview.FloatingSearchView
android:id="@+id/floating_search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:floatingSearch_searchHint="Search..."
app:floatingSearch_suggestionsListAnimDuration="250"
app:floatingSearch_showSearchKey="false"
app:floatingSearch_leftActionMode="showHamburger"
app:floatingSearch_menu="@menu/searchbar_sidemenu"
app:floatingSearch_close_search_on_keyboard_dismiss="true"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="10dp"/>
menu code:
<?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">
<item android:id="@+id/action_notification"
android:title="Notification"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_notifications_none_black_24dp"/>
</menu>
I tried other answer but none of them worked for me.
I will explain/clarify or share java code if needed.
[Update]
I tried to implement this answer and other answer.
searched in GitHub repo and found this but did not understand.
Thanks to @Rinat for his comment
Here is details answer.
Download arimorty/floatingsearchview and import it as module (detailed answer for import) if you are using java you can just import library
folder from downloaded.
After importing open MenuView file src->main->java->com.arlib.floatingsearchview->util->view->MenuView.java
in this file find ImageView action = createActionView();
change action
to global field
create a new method in MenuView
public void chngNotificationIcon(int ResID){
action.setImageResource(ResID);
}
Open FloatingSearchView.java file and create this method as well
public void chngNotificationIcon(int ResID){ mMenuView.chngNotificationIcon(ResID); }
Create a new drawbale
in you main project for notification with red circle and name it notification_withdot.xml
now you can set any icon using
floatingSearchViewObject.chngNotificationIcon(R.drawable.notification_withdot);
let me know if you face any error.