Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split text in 2 textviews like if there were 1?

I have a listview where each item has 2 images, one on the right and the other on the left. Between them there is a textview that is filled from data. If text is long then it can continue down but there is a lot of free space just as you can see in the image. I want to use this space also to display text. I have been looking around the web and I have seen things like this http://code.google.com/p/android-flowtextview/downloads/detail?name=FlowTextDemo.zip&can=2&q= but this is useless. I don't want to lose the control of the images because I need their click method. What is the best way to do it? I have thought that maybe I can put a textview between images and an other down and when the first is filled continue in the second one but how can I know how many letters can keep the first textview?enter image description here

like image 316
Learning from masters Avatar asked Dec 25 '12 23:12

Learning from masters


1 Answers

I don't understand why FlowTextView (that you linked to) won't work for you. It's derived from RelativeLayout and flows text around any child views. The child views can be your images, positioned as you normally would in a RelativeLayout. Their onClick methods should work just fine.

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

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:onClick="onTopLeftClick"
        android:src="@drawable/top_left_image" />
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:onClick="onTopRightClick"
        android:src="@drawable/top_right_image" />

</com.pagesuite.flowtext.FlowTextView>

You will need to set the text in code, or else extend FlowTextView and define your own custom attribute(s) to do it from xml.

like image 80
Ted Hopp Avatar answered Oct 28 '22 17:10

Ted Hopp