0

テキストが動的にtextviewに割り当てられているtextViewがあります。

テキストビューを水平方向(右から左)にスクロールしています。TextViewのX座標を設定してスクロールしています。

私の問題は、画面幅(LCD幅)を超える長いテキストの場合、textviewは1行の範囲内のテキストのみを表示し、次に残りのテキストの新しい行を作成することです。

ただし、テキストを1行だけ保持し、画面上で水平方向にスクロールさせたいと思います。

4

6 に答える 6

1

XML レイアウトで singleLine と scrollHorizo​​ntally を true に設定する

<TextView
    android:id="@+id/txt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollHorizontally="true"
    android:singleLine="true"
    android:text="TextView" />

TextView は LCD の幅で構築されているため、X 座標の設定は機能しません。テキストを実際にスクロールするのではなく、ビューを移動するだけです。

于 2012-12-27T11:06:37.173 に答える
0

画面幅でテキストビューが壊れる問題は、相対レイアウトを使用していました。

レイアウト幅を 5000dp に設定して相対レイアウトを線形レイアウトに変更したところ、うまくいきました。

于 2012-12-29T11:32:30.207 に答える
0

プロパティを設定

android:singleLine="true"

テキストビュー用

于 2012-12-27T10:45:47.250 に答える
0

右側からパディングのプロパティを設定し、これとともに TextView または Select Single line プロパティの幅を設定できます

于 2012-12-27T10:47:24.770 に答える
0

これは簡単にできます。書くだけです。.

android:singleLine="true"

これにより、適切な範囲で EditText に大量のデータを書き込むことができます。

于 2012-12-27T11:08:29.687 に答える
0

これを試して

<HorizontalScrollView
            android:layout_width="fill_parent"
            android:layout_height="35dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="5dp"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:scrollbars="horizontal" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="35dp"
                android:gravity="center" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:text=""
                    android:gravity="center"
                    />
            </LinearLayout>
        </HorizontalScrollView>

これはあなたを助けるかもしれません

于 2012-12-27T11:05:13.140 に答える