Textview Cover Around View

I try to have my horizontal layouts use an accessible room.

In the activity information, I have a “fact box” followed by a large box of text. I want the infobox to float to the right, as shown in the following figure.

Is this possible with the Android TextView api?

Example picture

+26
android android-layout alignment wrap textbox
Sep 02 '10 at 11:45
source share
4 answers

I would suggest using WebView for this. You can format the text in a web view using the usual HTML / CSS formatting, with which your desired layout is pretty simple.

+3
Sep 02 '10 at 12:15
source share

found this solution !! check it from source ---> response source

How to add multiple layout elements

This is a problem that people may encounter when working with layouts on Android.

Suppose you want to place an image in the middle of a sentence. you can add a pair of TextView and ImageView, but if the horizontal space gets too small, the two TextViews will begin to wrap independently, which will look strange. You want the image to be part of your TextView and the whole sentence to wrap it around beautifully. To do this: * replace three objects with one Spannable TextView * use SpannableStringBuilder to add all your lines (do not forget to add an additional character (for example, a space), which will be replaced by your image) * and finally use setSpan (ImageSpan, begin, end , flag) in this builder, where ImageSpan is ImageSpan containing the popped snapshot of your image, the beginning is the index of the character you entered

And here is the code:

add android: bufferType = "spannable" to your TextView

SpannableStringBuilder builder = new SpannableStringBuilder(); builder.append(mContext.getText(R.string.part1)); int lengthOfPart1 = builder.length(); builder.append(" "); builder.append(mContext.getText(R.string.part2)); Drawable d = mContext.getResources().getDrawable(R.drawable.picasaIcon); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); // <---- Very important otherwise your image won't appear ImageSpan myImage = new ImageSpan(d); builder.setSpan(myImage, lengthOfPart1, lengthOfPart1 + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); myTextView.setText(builder); 
+10
Apr 04 2018-11-11T00:
source share

I know this late, but for people who are still trying to do this, here is a library whose goal is to achieve just that. https://github.com/deano2390/FlowTextView

+6
Feb 12 '15 at 20:23
source share

I am afraid that this is not possible with a single TextView. TextView must be a rectangle and cannot display child views. The workaround may be to create two TextViews and the first section of the text, then in the first text view, specify how much it can display, and add the rest of the line to the second text view.

+2
Sep 02 '10 at 11:56
source share



All Articles