【问题标题】:How to add label in a SearchView outside of action bar?如何在操作栏外的 SearchView 中添加标签?
【发布时间】:2018-02-15 10:24:43
【问题描述】:

Screenshot

如何在SearchView 中添加标签?起初我使用ImageButtonText 组合来实现我想要的显示。 (见截图,第 2 行)我切换到 SearchView,我想知道如何修改它的外观,使其与 ImageButton/Text 组合相同?

【问题讨论】:

    标签: android android-layout android-widget searchview


    【解决方案1】:

    向搜索视图添加提示。看到这个documentation

    创建可搜索的配置

    可搜索配置定义 SearchView 的行为方式,并在 res/xml/searchable.xml 文件中定义。至少,可搜索的配置必须包含一个 android:label 属性,该属性的值与 Android 清单中 or 元素的 android:label 属性值相同。但是,我们还建议添加一个 android:hint 属性,让用户知道要在搜索框中输入什么:

    <?xml version="1.0" encoding="utf-8"?>
    <searchable xmlns:android="http://schemas.android.com/apk/res/android"
            android:label="@string/app_name"
            android:hint="@string/search_hint" />
    

    【讨论】:

      猜你喜欢
      • 2017-06-11
      • 2014-11-26
      • 2013-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多