I am getting a problem in putting imageview just after textview if textview becomes of two line.
I want to show this(Image just after text,text can be in one line,two line or three lines)
My imageview comes just after textview if text is short(one line).
But when text becomes longer(two lines) then image goes to next line like this
I know the reason of this problem but don't know how to solve?
After lot of googling, I found a good solution of my problem
TextView textView =new TextView(this);
SpannableStringBuilder ssb = new SpannableStringBuilder( "Here's a smiley how are you " );
Bitmap smiley = BitmapFactory.decodeResource( getResources(), R.drawable.movie_add );
ssb.setSpan( new ImageSpan( smiley ), ssb.length()-1, ssb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE );
textView.setText( ssb, BufferType.SPANNABLE );
With the help of above code, you can add image any where in Textview.
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