SearchView in AppCompat Distorts Icon

I am stuck in a very strange situation, my SearchView is working fine. I just need to use OnActionExpandListener and for this purpose, I have to install the application: showAsAction = "ifRoom | collapseActionView" in my SearchView element in the menu layout.

What he does, he distorts the SearchView icon. If I use the application: showAsAction = "always" , OnActionExpandListener stops working, but the icon displays fine.

Any help in this regard would be greatly appreciated, thanks.

Edit: See Comments on the answer.

+4
source share
1 answer

I agree, they did not cope with this. Anyway, I use this instead to detect when it SearchViewexpands / closes.

searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
        @Override
        public void onViewAttachedToWindow(View v) {
            // Opened
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            // Closed
        }
    });
+1
source

All Articles