Margin between SearchView and collapseIcon in toolbar

后端 未结 2 1083
北海茫月
北海茫月 2020-12-18 23:46

I\'m trying to implement android.support.v7.widget.SearchView with a collapseIcon on the Toolbar. Everything works fine i.e, the

相关标签:
2条回答
  • 2020-12-18 23:57

    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;
    

    for the following LinearLayout inside the SearchView:

    LinearLayout searchEditFrame = (LinearLayout) searchView.findViewById(R.id.search_edit_frame);
    
    0 讨论(0)
  • 2020-12-19 00:09

    The problem can be solved by setting the leftMargin = 0 in the layout parameters associated with the following LinearLayout in the SearchView:

    (To get the layout parameters use the getLayoutParams)

    LinearLayout searchEditFrame = (LinearLayout) searchView.findViewById(R.id.search_edit_frame); // Get the Linear Layout 
    // Get the associated LayoutParams and set leftMargin
    ((LinearLayout.LayoutParams) searchEditFrame.getLayoutParams()).leftMargin = 0;
    
    0 讨论(0)
提交回复
热议问题