テーブル行内のテキストビューのテキストを複数行に表示しようとしていますが、何らかの理由で適切に折り返されておらず、最終的にこれになります(スクリーンショットを参照)。テキストビューにこれを行うための何かがあることは知っていますが、この問題が発生する原因がわかりません。この問題を解決するために何ができますか?
スクリーンショット
リストアイテムXML
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<ImageView
android:id="@+id/img"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
指定する必要がありますandroid:layout_weight="1"
。
この値は
TableRow
、TextView
がと同等である必要があることを示していますmatch_parent
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
>
<ImageView
android:id="@+id/img"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"/>
<TextView
android:id="@+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_weight="1"
android:text="This is a long long long long text fodshfkjsdkjfjsh js hdfjksh kjdhf kjshdkjf"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
</TableLayout>
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加