8

テキストビューに表示されるテキストがスペースよりも長い場合に備えて、テキストを上下にスクロールしたい。ただし、私がテストした以下の方法は機能しません。

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" />
4

3 に答える 3

16

の中に、またはViewのようなスクロール可能なものを含めることはできません。したがって、通常のレイアウト内でシンプルを使用し、それにプロパティを追加します。TextViewListViewScrollViewTextViewandroid:scrollbars

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:lines="3"
    android:scrollbars="vertical"
    android:scrollbarStyle="insideOverlay"
    android:fadeScrollbars="true"
    android:fadingEdge="vertical" />

サイドでは、次のActivityように書く必要があります。

tv1.setMovementMethod(new ScrollingMovementMethod());

(基本的に最初のポイントで説明したものと同じです)

于 2012-12-02T20:10:45.870 に答える
3

次のように試すことができます:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:fillViewport="true" >

    <LinearLayout

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:orientation="vertical" >

    <TextView
        android:id="@+id/TEXT_STATUS_ID"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1.0"/>
</LinearLayout>
</ScrollView>
于 2012-12-02T19:52:19.070 に答える
1
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <TextView
    android:id="@+id/TEXT_STATUS_ID"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

</ScrollView>
于 2012-12-02T19:47:57.937 に答える