I need to put the search image lens as hint in EditText. is it possible to do it in Android?
best regards,,
To label an editable TextView or EditText , use android:hint to display a descriptive text label within the item when it's empty. If an app's user interface already provides a text label for the editable item, define android:labelFor on the labeling View to indicate which item the label describes.
Right click on res folder → New → Vector Asset . Adjust the size from (24dp x 24dp) to (18dp x 18dp), choose the icon that you want by clicking on the android icon, click “Next” button and then click “Finish”. 3- Open activity_main. xml file and add 4 android edittext: Name, email, password and phone number.
Use the android:drawableLeft property on the EditText. This was just the solution I expected, given the search heading. Also, adjust the padding using the drawablePadding property. so what should be the size of that drawable icon and in which folder should i place it?
I always have solved this by changing the drawable right.
You can do it on the layout xml file android:drawableRight="@drawable/search_icon" or programmatically using the setCompoundDrawablesWithIntrinsicBounds function.
Hope it helped! :)
set background with search icon to editText and clear it on click event using textWatcher
, clickListener
or touchListener
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With