Search code examples
androidandroid-layoutuser-interfacetextview

How to let a TextView have multiple lines?


I want to show multiple line via TextView and strings.xml . I want to show first few lines until the middle of the page and other lines to show in full of the page. I want to show first few lines with same size of width page.

Left of the page is a picture and the right of the page is my sentences.

This is my code but this shows dishevel.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView 
    android:id="@+id/logoImage"
    android:src="@drawable/ic_launcher"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
<TextView
    android:id="@+id/txtIntroduce"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/txtIntroduce"
    android:textColor="@color/blue_text"
    android:background="@color/blue"/>
</LinearLayout>

strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <string name="intro">.................  ....</string>
<resources>

How can i show this view? Sorry for my poor english and thanks for your help.


Solution

  • It sounds like you want to wrap text around a picture, like so:

    --------------------
    |..........| xxxxxxx
    |..Picture.| xxxxxxx
    |..........| xxxxxxx
    ------------ xxxxxxx
    xxxxxxxxxxTextxxxxxx
    xxxxxxxxxxxxxxxxxxxx
    

    I think the easiest option is to a WebView. However, according to this you can also use image tags in a TextView. I've never tried it myself, but I have used the other tags like so: TextView.setText(Html.fromHtml("<b>some bold text</b> some normal text")) so maybe something similar will work in your situation.