这个问题在这里已有答案:
我有textview
,包括一个大文本,并填充父布局。但我不想使用Scrollview
,我想改变textview
属性。如何垂直滚动textview
?
您可以将textview
作为scrollView
的孩子,并使textview
作为包装内容的高度。
一个通用的方法是将你的顶级布局包装在<ScrollView>
中,如下所示:
<ScrollView
android:id="@+id/yourScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp">
<LinearLayout
android:id="@+id/yourMainLayout"
android:orientation="vertical"
android:padding="12dp" <!-- add your other content here -->
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
然后,在上面的LinearLayout
内你可以添加一个或多个TextView
。
在textview
xml中添加:
android:scrollbars = "vertical"