为什么我的scrollHorizo​​ntally不起作用?

Gab*_*ado 5 android scroll

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
tools:context=".MainActivity" >

<TextView
    android:id="@+id/instruction_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollHorizontally="true"
    android:text="@string/Texto_de_abertura"
    android:textColor="#00FF00" />

<TableRow>code<TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的代码.字符串Texto_de_abertura真的很大,并且它一直使用很多行来将整个字符串放在屏幕上,而不仅仅是一个我想要的水平滚动.

Hug*_*ade 6

要水平滚动,可以将TextView放在Horizo​​ntalScrollView中:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
tools:context=".MainActivity" >

    <HorizontalScrollView 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

        <TextView
        android:id="@+id/instruction_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollHorizontally="true"
        android:text="@string/Texto_de_abertura"
        android:textColor="#00FF00" />

   </HorizontalScrollView>

<TableRow></TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)

Android文档将scrollHorizo​​ntally描述为"文本是否允许宽于视图(因此可以水平滚动)"意味着需要使用Horizo​​ntalScrollView使视图滚动并设置属性以允许滚动.https://developer.android.com/reference/android/widget/TextView.html#attr_android:scrollHorizo​​ntally