本文介绍了Android SearchView - 向右移动图标(不带 ActionBar)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的安卓 SearchView -

I have an android SearchView like so -

 <SearchView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:queryHint="Search the forum ..."
        android:iconifiedByDefault="true"
        android:id="@+id/search_forum"
        android:layout_alignParentRight="true"
        android:textColor="#aaa" />

这不在我的 ActionBar 中,它在我的 Activity 中的其他地方.

This is not in my ActionBar, it's somewhere else in my activity.

我需要将图标(搜索图标)留在布局的右侧.单击它应该扩展到 SearchView(与 ActionBar SearchView 相同的行为).我试过 android:layout_alignParentRight="true" 但图标停留在左边.

I need the icon (the search icon) to stay on the right of my layout. On click it should expand into the SearchView (same behaviour as the ActionBar SearchView). I've tried android:layout_alignParentRight="true" but the icon stays to the left.

任何帮助都会很棒:)

推荐答案

我找不到确切的答案,所以我做了这个-创建带有搜索图标的图像视图.把它放在我的布局的右边.单击时,使搜索视图可见并设置图标化 false 并请求搜索视图的焦点.

I couldn't find an exact answer to this so I did this-Create an image view with search icon. Placed it on the right of my layout.On click, made the search view visible and set iconified false and requested focus for the search view.

如果有人最终能帮我找到合适的解决方案,我将不胜感激.

I'd be so grateful if somebody could eventually help me find a proper solution for this.

这篇关于Android SearchView - 向右移动图标(不带 ActionBar)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 03:05