How to remove inner bottom space (bottom margin/padding) of text/layout inside a SearchView?

你离开我真会死。 提交于 2019-12-24 13:52:40

问题


So I got this SearchView that has a default space at the bottom for the text inside it. How can I reduce it (see the red lines in picture):


回答1:


  1. Imagine you have SearchView named: searchBar

    SearchView searchBar = (SearchView) findViewById(R.id.searchViewBar);
    
  2. Get the view (AutoCompleteTextView) that holds the text inside your SearchView:

     //The view that contains the SearchView text
     AutoCompleteTextView searchTextContent = (AutoCompleteTextView) searchBar.findViewById(searchBar.getContext().getResources().getIdentifier("android:id/search_src_text", null, null));
    
     searchTextContent.setTextSize(15); //Set the text size
     searchTextContent.setGravity(Gravity.BOTTOM); //Set its gravity to bottom
    

You can use AutoCompleteTextView methods such as setHeight(), setPadding(), and many more to manipulate this view. More info here.



来源:https://stackoverflow.com/questions/33872724/how-to-remove-inner-bottom-space-bottom-margin-padding-of-text-layout-inside-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!