I'm making a mobile application, which I'm looking for to make a search engine, but I'd like to type the magnifying glass icon on the keyboard in the edittext of the search, how is that possible?
Instead of an EditText you can use the SearchView widget.
<android.support.v7.widget.SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.SearchView>
EditText
with magnifying glass. An option using the EditText
is defining the icon using the android:drawableLeft
property, and using the android:hint
property for the text:
<EditText
android:id="@+id/edtSearchProduct"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Busca en Twitter"
android:drawableLeft="@drawable/ic_magnifglass" />
But it is advisable to use the widget SearchView that has implemented the animation and deletion of text within the widget:
<SearchView
android:id="@+id/searchSomething"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
For the suggestion text use the property android: queryHint , example:
android:queryHint="Busca en Twitter"