简体   繁体   中英

Android EditText like Google Search EditText

Is there somewhere the code of Google Search in Android? The xml-layout would be enough for me. Or maybe there is a possibility to add a button to the right of the EditText just like adding an icon in the corner? Thanks. 在此输入图像描述

 <LinearLayout
        android:id="@+id/mainLayout"  
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/bar"//set back ground for total look
        android:orientation="horizontal" >            
        <EditText 
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:hint="Your hint"
             android:drawableRight="@drawable/search"//give your search icon
             android:id="@+id/editBox"
                         />            
        <Button                 
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:id="@+id/imageSpeak"
             android:background="@drawable/iconSpeak"//icon for speak
           />


</LinearLayout>     

You have a LinearLayout with horizontal orientation where you can have an EditText, an ImageView with the search image and an ImageView for the microphone image. All of them should have the required background images cut in such way in order to seem as one. This is the general notion.

Regarding the source code, I can't help you!

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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