本文介绍了如何将SearchView的搜索图标移到右侧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的布局,使用android.support.v7.widget.SearchView
.我想将搜索图标移到右侧,但没有找到任何方法...`
Here is my layout, using android.support.v7.widget.SearchView
.I want to move the search icon to the right side,but I haven't found any method...`
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:popupTheme="@style/AppTheme.PopupOverlay">
<android.support.v7.widget.SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tab_main_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
`
单击图标后,它将更改为此布局
after i click the icon,it will change to this layout
推荐答案
您可以通过编程方式完成
You can do it programmatically
SearchView search = (SearchView) item.getActionView();
search.setLayoutParams(new ActionBar.LayoutParams(Gravity.RIGHT));
这篇关于如何将SearchView的搜索图标移到右侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!