user1324936 user1324936 - 2 years ago 77
Android Question

Android: Linear Layout new Line

I created a LinearLayout like below with TextView. The Text is variable. If the Elements gets bigger than the Layout width it gets nasty. I want to have the text flow to a new line just one would do when writing a book. Is this possible?

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xx"
android:textAppearance="?android:attr/textAppearanceSmall" />

<EditText ...>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xx"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>


edit

like this:


  1. textview1text edittext textview2

  2. textview2continuesin2ndrow



not like this:


  1. textview1text edittext textview2text

  2. textview1cont


Answer Source

Try something like...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" >
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="xx"
            android:textAppearance="?android:attr/textAppearanceSmall" />
        <EditText ...>
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="xx"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>
</LinearLayout>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download