How to fill the empty spaces with content below the Image in android
Asked Answered
C

2

18

I have one ImageView and a TextView in my xml layout. I want to show the text below that i got by webservice on the right side of the ImageView. Can i show that text by using that one TextView ?

enter image description here

I tried to give android:singleLine="false" in xml layout but no use.

Cyanate answered 23/11, 2012 at 10:14 Comment(0)
T
23

https://github.com/deano2390/flowtextview

screenshot

Example usage:

 <com.pagesuite.flowtext.FlowTextView
     android:id="@+id/tv"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content" >

     <ImageView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:padding="10dip"
         android:src="@drawable/android" />

     <ImageView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
         android:layout_marginTop="400dip"
         android:padding="10dip"
         android:src="@drawable/android2" />

</com.pagesuite.flowtext.FlowTextView>

your code:

for Text:

tv = (FlowTextView) findViewById(R.id.tv);                  
tv.setText("my string"); // using plain text    
tv.invalidate(); // call this to render the text

for HTML:

tv = (FlowTextView) findViewById(R.id.tv);              
Spanned spannable = Html.fromHtml("<html ... </html>");
tv.setText(spannable);  // using html
tv.invalidate(); // call this to render the text
Tapley answered 23/11, 2012 at 10:27 Comment(5)
i am getting text from webservice how can i set that text to htmlCyanate
You dont have to convert it to html. dont use spanable just tv.setText(yourtextfromwebservice);Tapley
how can i convert that webservice text to html @talhakosenCyanate
I edited my post check there , There are 2 types of usage flowtextview. one of them is html, other is plain text.Tapley
lagy. even the sample of library is not scrolling smoothelyGesualdo
D
1

This has been discussed here : Textview wrap around View and here wrap text view around img view

Apparently, a solution is to use a Spannable and an ImageSpan as described is this answer Textview wrap around View

Another solution is to use a webview and make you layout in html.

Divebomb answered 23/11, 2012 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.