Good evening,
I am trying to wrap my text around an image view like the question is asking here:
in landscape.
but I wish to not do it in HTML / CSS. plus, that question is 2 years old. I am hoping someone has figured out a work around with this.
Also, I wish to keep my portrait view the way it is with the img view under the text view i.e. no wrapping.
Can anyone help me?
A work around I can think off the top of my head and from previous issues with
TextViewformatting, the best way is to have, say, aRelativeLayout, and just place 3 separate Views inside of it. It will represent theTextViewthat is right next to the image, theImageViewitself next to the text, and then the lastTextViewunder the first text, but with thelayout_width="match_parent". There is no other way to do this with theTextVieworImageViewotherwise.EDIT:
The only other workaround I believe you can do if you are so intent on using 1 TextView, I would suggest using
SpannableStringBuilderwithSpannableString. I didn’t originally give you that as an option for a specific reason. If you go back to that link you posted on your question, one of the answers say they found an answer. I believe that person linked to a good resource, but they are wrong for what your needs are. When usingSpannableStringBuilder, you are essentially creating a string that can have potentially many different version of a single string into one, like 3 different colors on a single string, or strings with 3 different sizes, all in oneTextView. Like what you need.Now the link talks about putting an image and having the text wrap around it nicely, but its not that simple, and that example isn’t what you need. What you could do to provide it all in one
TextViewis to add line breaks after the first few lines where you know the image will be to the right, and then not do so after the image. But the thing is it still needs to go in aRelativeLayout. But instead of two TextViews you only need one. Just place the TextView at the top left of whatever the parent is and the ImageView to the top right of whatever the parent is. This simulates afloatingelement. But I think doing it that way is more trouble than its worth. It really is because you have to do calculations to figure out where to put the line breaks, etc. You are better off using twoTextViews in which to make it look like you need. So in my opinion, DO NOT USESpannableStringBuilder, but if you do not mind trying to figure out all that spacing, that does give you what you need with a single TextView.