Android TextView AutoScroll

时间:2015-12-26 10:01:15

标签: android textview autoscroll

我正在尝试在表格布局中的textviews中实现自动滚动。我看到自动滚动只发生在第一个文本视图框而不是所有框中。

        <TableRow
            android:id="@+id/GuessWordtableRow1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="1dip"
            android:layout_weight="1"
            android:background="#d65906" >

            <TextView
                android:id="@+id/GuessWordtextView1a"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_margin="1dip"
                android:background="#fcc480"
                android:gravity="center"
                android:padding="1dip"
                android:text="1" >
            </TextView>

            <TextView
                android:id="@+id/GuessWordtextView11"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:singleLine="true"
                android:ellipsize="marquee"
                android:marqueeRepeatLimit="marquee_forever"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:scrollHorizontally="true"
                android:layout_margin="1dip"
                android:layout_weight="1"
                android:background="#fcc480"
                android:clickable="false"
                android:gravity="center_vertical"
                android:padding="1dip"
                android:text="This is a very big statement which has to scroll" >

            </TextView>

            <TextView
                android:id="@+id/GuessWordtextView12"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:singleLine="true"
                android:ellipsize="marquee"
                android:marqueeRepeatLimit="marquee_forever"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:scrollHorizontally="true"
                android:layout_margin="1dip"
                android:layout_weight="1"
                android:clickable="false"
                android:gravity="center_vertical"
                android:background="#fcc480"
                android:padding="1dip"
                android:text="This is a very big statement which has to scroll" >
            </TextView>

            <TextView
                android:id="@+id/GuessWordtextView13"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:singleLine="true"
                android:ellipsize="marquee"
                android:marqueeRepeatLimit="marquee_forever"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:scrollHorizontally="true"
                android:layout_margin="1dip"
                android:clickable="false"
                android:layout_weight="1"
                android:gravity="center_vertical"
                android:background="#fcc480"
                android:padding="1dip"
                android:text="This is a very big statement which has to scroll" >
            </TextView>
        </TableRow>

这就是我所拥有的。我看到文本只滚动textview id GuessWordtextView11而不是GuessWordtextView12和GuessWordtextView13。可能是什么原因?

3 个答案:

答案 0 :(得分:1)

更改为/添加此属性到TextViews:

android:gravity="bottom"
android:scrollbars="vertical"

答案 1 :(得分:0)

附上<ScrollView>

答案 2 :(得分:0)

所有 TextView

滚动

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TableRow
    android:id="@+id/GuessWordtableRow1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="1dip"
    android:background="#d65906" >

    <ScrollView
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_weight="1">

        <TextView
            android:id="@+id/GuessWordtextView1a"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="1dip"
            android:background="#fcc480"
            android:gravity="center"
            android:padding="1dip"
            android:text="@string/long_string" >
        </TextView>
    </ScrollView>

    <ScrollView
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_weight="1">

        <TextView
            android:id="@+id/GuessWordtextView11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="1dip"
            android:background="#fcc480"
            android:gravity="center"
            android:padding="1dip"
            android:text="@string/long_string"  >

        </TextView>
    </ScrollView>


    <ScrollView
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_weight="1">

        <TextView
            android:id="@+id/GuessWordtextView12"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="1dip"
            android:background="#fcc480"
            android:gravity="center"
            android:padding="1dip"
            android:text="@string/long_string"  >

        </TextView>
    </ScrollView>


    <ScrollView
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_weight="1">

        <TextView
            android:id="@+id/GuessWordtextView13"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="1dip"
            android:background="#fcc480"
            android:gravity="center"
            android:padding="1dip"
            android:text="@string/long_string"  >

        </TextView>
    </ScrollView>

</TableRow>