0

私は2つのテキストビューでリストビューを実装しており、参考のために基本的なレイアウトとフォーマットを使用しています

短い銘柄名の代わりに長いテキストを使用しているため、長いテキストを使用すると 2 番目の .

2つのテキストビューが互いに重ならないようにするにはどうすればよいですか。

4

3 に答える 3

0

次のコードを使用して、問題を解決できます。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:weightSum="1">
    <TextView
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:id="@+id/ticker_symbol"

         android:text="sdasd sadas"
         android:layout_weight=".5"/>
    <TextView
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:id="@+id/ticker_price"
         android:text="dfsd"
         android:layout_weight=".5"
         android:gravity="right" />
</LinearLayout>

出力:

コードの出力

于 2012-06-21T14:05:49.910 に答える
0

テキストの長さが長いため、次の行または次のTextViewに移動するという意味だと思います

したがって、textViewプロパティandroid:ellipsized = "end"を使用し、代わりにandroid:single_line = "true"を使用することをお勧めします。これは、maxline = 1を直接指定できます。名前のスペルが正しいかどうかわからないため、入力時に確認してください。

<TextView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/ticker_symbol"
        android:ellipsezed="end"
        android:singe_line="true"  
        android:layout_alignParentLeft="true" />

この説明があなたのためにうまくいくことを願っています。

于 2012-06-21T14:07:25.640 に答える
0

重複を避けるために、2 番目のテキストビューを右揃えに設定できます (android:layout_toRightOf)。

例えば:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/ticker_symbol"
        android:layout_alignParentLeft="true" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/ticker_price"
        android:layout_toRightOf="@id/ticker_symbol"
        android:layout_alignParentRight="true"  />
</RelativeLayout>
于 2012-06-21T13:55:16.443 に答える