How to add icon image as tooltip for EditBox in Android

I need to put the lens of the search image as a tooltip in an EditText. can this be done in android?

Best wishes,

+6
source share
3 answers

I always solved this by changing the edit.

You can do this in the xroid file android: drawableRight = "@ drawable / search_icon" or programmatically using the setCompoundDrawablesWithIntrinsicBounds function.

Hope this helps! :)

+18
source

set the background using the search icon in editText and clear it on a click event using textWatcher , clickListener or touchListener .

+3
source

I have exactly what you asked for permission. It works great, but keep in mind that Unicode support does not work on Android.

1) Select the character you like in unicode here http://www.fileformat.info/info/unicode/char/1f50e/index.htm then select a font that supports it (and has a visual representation that matches your design).

2) Download this font (watch out for licensing and ttf file size)

3) Put the downloaded font in the resource folder, for example, Symbola.ttf

4) Do it in your creation method

  Typeface font = Typeface.createFromAsset(getAssets(), "Symbola.ttf"); txtSearch.setHint("\uD83D\uDD0E"); txtSearch.setTypeface(font); //Unfortunatly you can't define "\uD83D\uDD0E" in strings xml, that is not supported. 

5) If you do not like the characters in the font set txtSearch.setTypeface (Typeface.DEFAULT); when the user begins to enter text (use the text observer onTextChanged (...))

0
source

Source: https://habr.com/ru/post/901235/


All Articles