I have a search feature in my app, where I can move up and down icons in the Menu. If I tap on the up and down icon I can see the ripple effect on the icon. Now I want to perform up icon functionalities when I tap the search button from the keyboard. To achieve this programmatically I made up icon click action. I can get up icon functionalities but I can't make a ripple effect on the icon. Any workaround to make a ripple effect on the icon?
Below code, I have used to make the menu programmatically clicked.
searchEdit.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
actionUpMenuItem?.let {
onOptionsItemSelected(it)
}
true
} else {
false
}
}
and also I tried this, I can't see the ripple effect in both function
searchEdit.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
optionMenu?.performIdentifierAction(R.id.action_up, 0)
true
} else {
false
}
}
This is the menu item 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_up"
android:foreground="?attr/selectableItemBackground"
android:icon="@drawable/ic_search_up_arrow"
android:orderInCategory="94"
android:title="@string/description_item_up"
app:showAsAction="always" />
<item
android:id="@+id/action_down"
android:foreground="?attr/selectableItemBackground"
android:icon="@drawable/ic_search_down_arrow"
android:orderInCategory="95"
android:title="@string/description_item_down"
app:showAsAction="always" />
</menu>
Create your custom ripple effect ripple_effect_small_corner
create drawable list_item_background_small_corner
You can use like this:
android:background="@drawable/ripple_effect_small_corner"