0

次のような複数の行を持つテーブルがあります。

<TableRow
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textSize="12sp"
        android:layout_gravity="right|center_vertical"
        android:layout_margin="4dip" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="some text"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textSize="13sp"
        android:textStyle="bold"
        android:layout_gravity="left|center_vertical"
        android:layout_margin="4dip"
        android:ellipsize="end"
        android:lines="1"
        android:scrollHorizontally="true"
        android:layout_weight="1" />

    <ImageView
        android:src="@drawable/disclosure_indicator"
        android:contentDescription="@string/emptyString"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:scaleType="fitXY" />

</TableRow>

ただし、テキストビューのいずれかの行が残りのスペースよりも広い場合、2番目のテキストビューでは最後の「単語」が「...」に置き換えられます。

したがって、次のようなものを使用します。

"Some sort string"
"Some string that is a little bit longer"
"Singleword"

テーブルは次のようにレンダリングされます。

text | Some short...                       | >
text | Some string that is a little bit... | >
text |                                     | >

最初の行の文字列全体を表示するのに十分なスペースがあることが明らかな場合。切り捨て/省略が各行で正しく機能するようにするにはどうすればよいですか?

4

1 に答える 1

-1

@MarSara9 2 番目のテキスト ビューのレイアウト グラビティを変更します。このソリューションは、サンプルコードで機能しました:

android:layout_gravity="center_vertical"

于 2012-04-20T22:27:04.693 に答える