Android 2.3.3 でテキストを複数行に折り返すように TextView を取得しようとしていましたが、最も基本的なレベルであっても機能させることができません。何をしても、テキストは常に画面の端で途切れます。Android 4 でも問題なく動作しますが、2.3.3 もターゲットにしたいと考えています。
ここで基本的な部分だけを試しました:
<?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>
しかし、それでもテキストはラップされません。これを機能させようとしている私の実際のレイアウトは次のとおりです。
<?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>
編集: 何を変更したか正確には思い出せませんが、この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>