I have a searchView which looks like this:
private void setupSearchView() {
mSearchView = (SearchView) getActivity().findViewById(
R.id.search_vi
A search widget that intercepts all touches on its children and does a callback on touch down:
class InterceptTouchSearchView(context: Context, attrs: AttributeSet) : SearchView(context, attrs) {
var onActionDownIntercepted: (() -> (Unit))? = null
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
return true
}
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(ev: MotionEvent?): Boolean {
if (ev?.action == MotionEvent.ACTION_DOWN) {
onActionDownIntercepted?.invoke()
}
return false
}
}
Usage: search_view.onActionDownIntercepted = { onSearchFieldClicked() }