左侧带有提示和搜索图标的搜索框 [英] Searchbox with hint and search icon on left

查看:52
本文介绍了左侧带有提示和搜索图标的搜索框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个searchview,它应该有一个搜索图标和提示(如在EditText 中).android 中的默认搜索视图只有搜索图标 .它没有像edittext这样的提示.

I want to to create a searchview which should have a search icon and hint (as in EditText) . The default searchview in android has only the search icon . It does not have hint like edittext.

我可以向 searchview 添加提示,但只有在单击 search-view 上的搜索图标后才可见.我正在使用以下代码向搜索视图添加提示.

I am able to add hint to searchview but it is only visible after clicking on the search icon on the search-view . I am using the following code to add hint to the search-view .

String locationSearchViewSetQueryHint = "<font color = #ffffff>Location</font>" 
     locationSearchView.setQueryHint(Html.fromHtml(locationSearchViewSetQueryHint))

如何显示带有搜索图标的提示?

How can I show the hint with search icon?

推荐答案

使用这个

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="40dp"
    android:layout_marginRight="40dp"
    android:layout_marginTop="10dp"
           android:padding="5dp"
    android:background="@drawable/edit_text_bg"
    android:gravity="left"
    android:hint="Search"
    android:drawableStart="@drawable/search_icon">

这篇关于左侧带有提示和搜索图标的搜索框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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