簡體   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