4

次の簡単なコードを見てください。

 <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="John Jonathan Samuwell Abbruzzi"
        android:singleLine="true"
        android:scrollHorizontally="true"
        android:textSize="50sp" />

のテキストTextViewは画面の幅よりも大きく、1 行にする必要があります。を追加android:scrollHorizontally="true"したので、ユーザーはスクロールして残りのテキストを表示できます。しかし、それは起こっていません。私は何を間違えましたか?

4

2 に答える 2

1

単一行で Horizo​​ntalScrollView を使用する必要があります。複数のビューに水平スクロールバーが必要な場合は、Horizo​​ntalScrollView でレイアウトを作成し、スクロールを完了できます。Horizo​​ntalScrollView は、直接の子を 1 つだけ保持できます。

<HorizontalScrollView
        android:id="@+id/horizontalScrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="40dp" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="91dp"
                android:singleLine="true"
                android:text="my view" />

    </HorizontalScrollView>
于 2013-11-04T07:21:14.873 に答える