Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving extra space in Search View Icon in Actionbar
    text
    copied!<p>I am working on customizing Android Actionbar in API level 11 and above. I have a custom view for Actionbar in which i have a SearchView widget with other icons. But when the search view is in icon shape(not in expanded form) it takes more than desired space(as shown in red below).</p> <p><img src="https://i.stack.imgur.com/D3i3O.png" alt="enter image description here"></p> <p>If i change my icon to a black image the following result is shown:</p> <p><img src="https://i.stack.imgur.com/RSw4n.png" alt="enter image description here"></p> <p>I have gone through the xml layout of the search view and have tried to reduce this padding by accessing individual views inside search view but the space does not get removed. The code i have written for the same is as below</p> <pre><code> searchView.setBackgroundColor(Color.RED); searchView.setPadding(0, 0, 0, 0); searchView.setIconifiedByDefault(true); int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_plate", null, null); View searchPlate = searchView.findViewById(searchPlateId); searchPlate.setBackgroundColor(Color.BLUE); searchPlate.setPadding(0,0,0,0); int searchTextId = searchPlate.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); final TextView searchText = (TextView) searchPlate.findViewById(searchTextId); searchText.setPadding(0,0,0,0); searchText.setBackgroundColor(Color.GRAY); int searchImgId = getResources().getIdentifier("android:id/search_button", null, null); ImageView v = (ImageView) searchView.findViewById(searchImgId); v.setBackgroundDrawable(null); v.setPadding(0, 0, 0, 0); v.setImageResource(R.drawable.search); </code></pre> <p>Can we do this by any means? I have noticed one thing that the search view xml layout uses padding.Can that be the reason for this? </p> <p>I have seen lot of post for customizing Actionbar and search view but no one answers my question exactly.</p> <p>Please suggest.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload