Maybe FlowTextView can solve your problem. FlowTextView is based on a RelativeLayout with added TextView features that wraps its text around its children.
Alternatively, if it's ok for you if the TextView is at the right and the image is at the left, like this:
---------
| Image | Text that is so
--------- long that it's
wrapping around the image
you could try the LeadingMarginSpan2:
Implement it like this:
public class MyLeadingMarginSpan2 implements LeadingMarginSpan.LeadingMarginSpan2 {
int lines;
int offset;
public MyLeadingMarginSpan2(int lines, int offset) {
this.lines = lines;
this.offset = offset;
}
@Override
public int getLeadingMarginLineCount() {
return lines;
}
@Override
public int getLeadingMargin(boolean first) {
return first ? offset : 0;
}
@Override
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
}
}
and use it like this in your code:
float textLineHeight = textView.getPaint().getTextSize();
int lines = (int) (imageView.getMeasuredHeight() / textLineHeight) + 1;
int offset = imageView.getMeasuredWidth();
SpannableString text = new SpannableString("Text that is so long that it's wrapping around the image");
text.setSpan(new MyLeadingMarginSpan2(lines, offset), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(text);
In case you want to provide an additonal fallback for very old versions of Android (< 2.2), you can have a look at this answer to a similar question: https://stackoverflow.com/a/8463221/13792619