如何在SearchView中删除文本/布局的内部底部空间(底部边距/填充)?
问题描述:
所以我得到了这个SearchView,它的底部有一个默认的空格.如何减少它(请参见图片中的红线):
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):
答
-
假设您有
SearchView
名为:searchBar
SearchView searchBar = (SearchView) findViewById(R.id.searchViewBar);
获取将文本保存在SearchView
中的视图(AutoCompleteTextView
):
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
您可以使用AutoCompleteTextView方法(例如setHeight(),setPadding()等)来操纵此视图.更多信息此处.
You can use AutoCompleteTextView methods such as setHeight(), setPadding(), and many more to manipulate this view. More info here.