Insert text inside edittext in android?

I am trying to insert a text view inside an Edittext as shown below

enter image description here

can anyone give me ideas on how to implement it or something like that.

thank:)

update: text images in the editor will change dynamically.

+5
source share
4 answers

I think you can’t install TextViewinside EditText. But, alternatively, you can make it look like this. Here are the steps

  • convert text image to BitmapDrawable
  • convert bitmap to SpanableString( ImageSpan)
  • then set this returned SpannableStringto yourEditText

ui, GoSmsPro/Evernote, EditText

+2

. .

PopupWindow pw = new PopupWindow(
                                 this.getViewInflate().inflate(R.layout.pw_layout, 
                                                               null, true, null), 
                                100,100,true);
// display the popup in the center
pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
pw.update(20,20,100,100);

EditText EditText. , , .

class emailEditText extends EditText {

List<NamePhotoView> ViewlistOfSelectedContacts; // create new

    void addContact(String name, Bitmap photo) {
       // create a new 'NamePhotoView' and add to the ViewlistOfSelectedContacts
    }

    @Override
    void onDraw(Canvas canvas) {
        for (....) {
            // draw all views from the list. left to right.
        }
    // you have to some how offset the text start coordinate. then call super
    super.onDraw(canvas);
    }
}
+3

Android , Chips UI, .
span, (, ..) , , .

+2

you can create a component based on what you need, as you mentioned above, with a frame. You can have a FrameLayout or RelativeLayout with two views, such as EditText and TextView, while the text view is on top of the EditText. You can also put an image if you want, just like your photo.

Although you do not need to create a component, and you can easily do this in your XML layout, if you plan to use it regularly through your application, it is good practice to create these views as a component.

+1
source

All Articles