user interface - Android searchView with voice icon -


in android app, want implement searchview enter image description here

there requirements:

  1. the searchicon , text("搜索")are in middle of searchview

  2. a voiceicon inside right side of searchview.

3.the searchview expanded default.

i try use android searchview component, can't move searchicon middle of searchview , dont konw how add voiceicon.

how can this,thanks.

i know shuold use custom layout this, write this:

 <linearlayout                     android:orientation="horizontal"                     android:background="@color/orange_yellow"                     android:gravity="center"                     android:layout_width="match_parent"                     android:layout_height="50dp">                     <relativelayout                         android:id="@+id/homesearchview"                         android:background="@color/white"                         android:layout_marginleft="10dp"                         android:layout_width="match_parent"                         android:layout_weight="5"                         android:gravity="center_horizontal"                         android:layout_height="wrap_content">                         <linearlayout                             android:orientation="horizontal"                             android:gravity="center"                             android:layout_width="match_parent"                             android:layout_height="wrap_content"                             android:layout_toleftof="@+id/voicesearchiconimageview"                             android:layout_tostartof="@+id/voicesearchiconimageview">                              <imageview                                 android:layout_width="wrap_content"                                 android:layout_height="wrap_content"                                 android:background="@drawable/ic_action_search"                                 android:id="@+id/searchiconimageview" />                              <textview                                 android:layout_width="wrap_content"                                 android:layout_height="wrap_content"                                 android:gravity="center"                                 android:text="@string/search"                                 android:id="@+id/textview" />                         </linearlayout>                          <imageview                             android:layout_width="wrap_content"                             android:layout_height="wrap_content"                             android:layout_weight="1"                             android:background="@drawable/ic_action_voice"                             android:id="@+id/voicesearchiconimageview"                             android:layout_alignparenttop="true"                             android:layout_alignparentright="true"                             android:layout_alignparentend="true" />                       </relativelayout>                      <imagebutton                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:layout_marginleft="5dp"                         android:layout_marginright="10dp"                         android:background="@drawable/ic_action_scan"                         android:id="@+id/scanimagebutton" /> </linearlayout> 

and seems work

enter image description here

the next step implement search logic searchview component.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -