テキストビューに表示されるテキストがスペースよりも長い場合に備えて、テキストを上下にスクロールしたい。ただし、私がテストした以下の方法は機能しません。
1 -tv1.setMovementMethod(new ScrollingMovementMethod());
さらに、このメソッドを使用すると、メソッドの呼び出しが機能しonFling()
なくなります。
2 -<ScrollView>
レイアウト XML での使用。また、このメソッドを使用すると、メソッドの呼び出しが機能しonFling()
なくなります。
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="@+id/TEXT_STATUS_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"/>
</ScrollView>
レイアウト XML の私の TextView は次のとおりです。
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2.26"
android:background="@drawable/green"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />