工具栏中SearchView和crashIcon之间的边距 [英] Margin between SearchView and collapseIcon in toolbar

查看:216
本文介绍了工具栏中SearchView和crashIcon之间的边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Toolbar上的collapseIcon实现android.support.v7.widget.SearchView.一切正常,即SearchView可以正常工作,但是我无法删除/减少SearchViewcollapseIcon之间的填充,如所附的屏幕快照所示.

I'm trying to implement android.support.v7.widget.SearchView with a collapseIcon on the Toolbar. Everything works fine i.e, the SearchView is working as expected but I'm unable to remove/ reduce the padding between the SearchView and collapseIcon, as visible in the attached screenshot.

关于如何做到这一点的任何想法?

Any ideas on how can I do that?

我尝试过:

app:contentInsetStartWithNavigation="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"

但这是行不通的.

推荐答案

我设法通过查看SearchView使用的xml文件解决了该问题,因此可以通过更改leftMargin来删除/减少填充值:

I managed to solve the problem by looking at the xml file that's used by SearchView, so the padding can be removed/reduced by changing the leftMargin value:

layoutParams.leftMargin = 0;

对于SearchView中的以下LinearLayout:

LinearLayout searchEditFrame = (LinearLayout) searchView.findViewById(R.id.search_edit_frame);

这篇关于工具栏中SearchView和crashIcon之间的边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆