1

いくつかの数字を表示するアプリウィジェットを作成しています。各数字の前にラベルが付いています。

レイアウトは次のようになります。

.-----------------------------.
| Label1       |  AAAAAAAAAAA |
| LongerLabelLabel2 | BBBBBBB |
| LongLabel3    | CCCCCCCCCC  |
'-----------------------------'

外側(垂直)のLinearLayoutが1つあり、各行は2つのTextViewを持つ水平のLinearLayoutです。

問題は、ラベルの幅と数字がウィジェットに対して広すぎる場合、数字が省略されることです。ラベルを楕円形にしたい。

たとえば、上記の状況は次のようになります。

.-----------------------------.
| Label1    |     AAAAAAAAAAA |
| LongerLabelLabel2 | BBBB... |
| LongLabel3 |    CCCCCCCCCC  |
'-----------------------------'

希望の代わりに

.---------------------------.
| Label1     |  AAAAAAAAAAA |
| LongerLabelL... | BBBBBBB |
| LongLabel3  | CCCCCCCCCC  |
'---------------------------'

私は私の人生のためにこれを解決する方法を理解することはできません。どんな助けでも大歓迎です。


私の現在のレイアウトは次のとおりです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="0dip"
    android:orientation="vertical"
    style="@style/WidgetBackground">


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              android:id="@+id/ROW1"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:paddingTop="7dip"
              android:paddingBottom="0dip"
              android:paddingRight="10dip"
              android:paddingLeft="10dip"
              android:orientation="horizontal">
        <TextView android:id="@+id/NAME1" android:singleLine="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" style="@style/Text.account" />
        <TextView android:id="@+id/BAL1"  android:singleLine="true" android:layout_width="fill_parent"  android:layout_height="wrap_content" android:gravity="right" style="@style/Text.balance" />
    </LinearLayout>

... (more similar rows in the outer layout)

</LinearLayout>
4

1 に答える 1

2

あなたの問題の一部は、android:layout_width="wrap_content"あなたのレーベルにあると思います。表示するのに十分なスペースがあるため、楕円形になるとはまったく期待していません。

LinearLayoutからに切り替えRelativeLayoutます。番号の「列」をandroid:layout_alignParentRight="true"およびとして定義しますandroid:layout_width="wrap_content"。ラベルの「列」をandroid:layout_alignParentLeft="true"android:layout_toLeftOf="..."(...数値列はどこにありますか)、およびとして定義しますandroid:ellpsize="end"。これにより、数値に必要なすべてのスペースが与えられ、ラベルが制限され、楕円形になります。

于 2010-08-02T20:58:47.857 に答える