テキストが動的にtextviewに割り当てられているtextViewがあります。
テキストビューを水平方向(右から左)にスクロールしています。TextViewのX座標を設定してスクロールしています。
私の問題は、画面幅(LCD幅)を超える長いテキストの場合、textviewは1行の範囲内のテキストのみを表示し、次に残りのテキストの新しい行を作成することです。
ただし、テキストを1行だけ保持し、画面上で水平方向にスクロールさせたいと思います。
XML レイアウトで singleLine と scrollHorizontally を 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 座標の設定は機能しません。テキストを実際にスクロールするのではなく、ビューを移動するだけです。
画面幅でテキストビューが壊れる問題は、相対レイアウトを使用していました。
レイアウト幅を 5000dp に設定して相対レイアウトを線形レイアウトに変更したところ、うまくいきました。
プロパティを設定
android:singleLine="true"
テキストビュー用
右側からパディングのプロパティを設定し、これとともに TextView または Select Single line プロパティの幅を設定できます
これは簡単にできます。書くだけです。.
android:singleLine="true"
これにより、適切な範囲で EditText に大量のデータを書き込むことができます。
これを試して
<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>
これはあなたを助けるかもしれません