滚动视图不显示滚动条

Scrollview doesn't show scrollbar

我的Android TextView xml 很简单,如下图,我用了ScrollView的样式,但是它不会显示滚动条,即使文本超出底部,我也没有办法看看外面有什么。请问如何启用滚动条? 我认为 "match_parent" 有问题但不知道如何解决。谢谢!

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#ffffff">

        <TextView
        android:id="@+id/textResult"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
            android:layout_below="@+id/buttonRecord"
        android:layout_marginTop="16dp"
        android:background="@drawable/back"
        android:editable="true"
        android:height="150dp"
        android:text=""
        android:enabled="false"

        android:scrollbars="vertical"
        style="@android:style/Widget.ScrollView"
            android:layout_alignRight="@+id/buttonRecord"
            android:layout_alignEnd="@+id/buttonRecord"
            android:layout_alignLeft="@+id/buttonRecord"
            android:layout_alignStart="@+id/buttonRecord" />

</RelativeLayout>

如果你想让内容滚动,或许可以尝试给它一个固定的高度?由于 layout_height,现在高度设置为 wrap_content。我认为您根本不应该使用 android:height

如果你想让一个固定高度的TextView随着滚动条垂直滚动, 定义您的 XML 布局文件:

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbars="vertical"
    android:text="@string/text_string" />

定义您的 Java class 文件:

TextView tv = (TextView) findViewById(R.id.textView);
tv.setMovementMethod(new ScrollingMovementMethod());