繁体   English   中英

自定义外观searchView android

[英]Custom looking searchView android

我需要创建一个自定义外观的SearchView,当按下MainActivity.xml中已经具有的ImageButton时,该ViewView将打开。

如果您能解释一下该怎么做,我将不胜感激,因为我在SO上只能找到没有自定义外观的SearchView或将其永久地放在他们的TitleBar上的人,这是我使用光以来一直没有的。 NoTitleBar主题。

这是我需要的样子,这是我用photoshop制作的设计:

搜索

您可以通过多种方式获得想要的设计信息。

我使用的解决方案(可能不是最好的)是将EditText(您的搜索字段)放在FrameLayout中,这样我可以有一个搜索按钮,并删除与textView重叠的文本按钮:

XML范例:

<FrameLayout
 android:id="@+id/SearchTextInputLayout"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:layout_gravity="center"
 android:minWidth="100.0dp">
  <EditText
   android:id="@+id/SearchTextInput"
   android:textColorHint="@layout/inputselector"
   android:hint="Search terms here..."
   android:textAppearance="?android:attr/textAppearanceMedium"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   />
    <Button
      android:id="@+id/ClearSearchButton"
      android:layout_width="25dp"
      android:layout_height="25dp"
      android:layout_marginEnd="10dp"
      android:layout_marginRight="10dp"
      android:layout_gravity="end|center_vertical"
      android:background="@android:drawable/ic_delete" />
</FrameLayout>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM