Creating Custom EditText containing TextIcon

In this tutorial i will show how to create a EditText which will show some info on right of EditText. Sometimes we need to show some kind of hint or data next to EditText but for that we have to add extra layout for showing that data. To solve this problem we will be creating our own Custom EditText as shown in below picture.

Logic for Custom EditText

The logic for custom EditText is to create a bitmap from drawable and then embed text in that bitmap and set this bitmap on right of custom EditText. Whenever text changes just update the text by redrawing the bitmap with updated text.

MyEditText.java

In this code i have created Bitmap from xml drawable resource. This was done by using canvas. After that paint object is created to draw on that bitmap. Lots of values used in this code are assumed and are found by hit and trial Suggestions in this case are welcomed.

For further queries please comment .

guru

Technology enthusiast. Loves to tinker with things. Always trying to create something wonderful using technology. Loves coding for Android, Raspberry pi, Arduino , Opencv and much more.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *