I have been trying to get a TextView to wrap the text to multiple lines on Android 2.3.3 for a while not but I can't seam to get it working, even on the most basic of levels. No matter what I do the text always just cuts off at the edge of the screen. It works just fine on Android 4 but I would like to target 2.3.3 as well.
I have tried just the basic part here:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/mainDescText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/A_MORE_DESCRIPTION_TEXT" />
</LinearLayout>
But that still doesn't wrap the text. My real layout that I am trying to get this to work on is here:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="55dp" >
<TextView
android:id="@+id/mainDescText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="2"
android:text="@string/A_MORE_DESCRIPTION_TEXT" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="80dp" >
<TextView
android:id="@+id/ageCurrentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ageButton"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:text="@string/A_MORE_CURRENT_SIGHTINGS_AGE" />
<Button
android:id="@+id/ageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:onClick="loadSightingsAge"
android:text="@string/A_MORE_SIGHTINGS_AGE_BUTTON" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginTop="10dp" >
<TextView
android:id="@+id/languageCurrentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/languageButton"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:text="@string/A_MORE_CURRENT_LANGUAGE" />
<Button
android:id="@+id/languageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:onClick="loadLanguage"
android:text="@string/A_MORE_LANGUAGE_BUTTON" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="@+id/redPinImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/red_pin"
android:contentDescription="@string/A_MORE_RED_PIN_IMAGE" />
<TextView
android:id="@+id/redPinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/redPinImage"
android:text="@string/A_MORE_RED_PIN_DESCRIPTION" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="@+id/yellowPinImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/yellow_pin"
android:contentDescription="@string/A_MORE_YELLOW_PIN_IMAGE" />
<TextView
android:id="@+id/yellowPinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/yellowPinImage"
android:text="@string/A_MORE_YELLOW_PIN_DESCRIPTION" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="@+id/greenPinImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/green_pin"
android:contentDescription="@string/A_MORE_GREEN_PIN_IMAGE" />
<TextView
android:id="@+id/greenPinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/greenPinImage"
android:text="@string/A_MORE_GREEN_PIN_DESCRIPTION" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<TextView
android:id="@+id/thanksText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/A_MORE_CREATED_BY_TEXT" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Edit: I can't remember exactly what I changed but I was able to get it to work with this xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="55dp" >
<TextView
android:id="@+id/mainDescText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="3"
android:scrollHorizontally="false"
android:text="@string/A_MORE_DESCRIPTION_TEXT" />
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="80dp" >
<TextView
android:id="@+id/ageCurrentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ageButton"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="@string/A_MORE_CURRENT_SIGHTINGS_AGE" />
<Button
android:id="@+id/ageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:onClick="loadSightingsAge"
android:text="@string/A_MORE_SIGHTINGS_AGE_BUTTON" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginTop="10dp" >
<TextView
android:id="@+id/languageCurrentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/languageButton"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="@string/A_MORE_CURRENT_LANGUAGE" />
<Button
android:id="@+id/languageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:onClick="loadLanguage"
android:text="@string/A_MORE_LANGUAGE_BUTTON" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="@+id/redPinImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/red_pin"
android:contentDescription="@string/A_MORE_RED_PIN_IMAGE" />
<TextView
android:id="@+id/redPinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/redPinImage"
android:lines="3"
android:scrollHorizontally="false"
android:text="@string/A_MORE_RED_PIN_DESCRIPTION" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="@+id/yellowPinImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/yellow_pin"
android:contentDescription="@string/A_MORE_YELLOW_PIN_IMAGE" />
<TextView
android:id="@+id/yellowPinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/yellowPinImage"
android:lines="3"
android:scrollHorizontally="false"
android:text="@string/A_MORE_YELLOW_PIN_DESCRIPTION" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="@+id/greenPinImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/green_pin"
android:contentDescription="@string/A_MORE_GREEN_PIN_IMAGE" />
<TextView
android:id="@+id/greenPinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/greenPinImage"
android:lines="3"
android:scrollHorizontally="false"
android:text="@string/A_MORE_GREEN_PIN_DESCRIPTION" />
</RelativeLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp" >
<TextView
android:id="@+id/thanksText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center"
android:lines="3"
android:scrollHorizontally="false"
android:text="@string/A_MORE_CREATED_BY_TEXT" />
</RelativeLayout>
</LinearLayout>
</ScrollView>