【问题标题】:How to make a textview scroll vertically? [duplicate]如何使文本视图垂直滚动? [复制]
【发布时间】:2019-07-08 02:21:52
【问题描述】:

我有textview,其中包含一个大文本并填充父布局。但我不想使用Scrollview,我想更改textview 属性。如何垂直滚动textview

【问题讨论】:

  • 请分享您的布局代码并添加您的问题的屏幕截图。

标签: java android textview


【解决方案1】:

您可以将textview 设为scrollView 的子级,并将textview 设为高度作为环绕内容。

【讨论】:

  • 这是我读到的关于如何使 textview 可滚动的最佳答案。我尝试了一切,直到我将 textview 的高度设置为 wrap_content.
【解决方案2】:

textview xml 中添加这个:

android:scrollbars = "vertical"

【讨论】:

    【解决方案3】:

    执行此操作的一种通用方法是将您的顶级布局包装在 <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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-22
      • 2011-07-27
      • 1970-01-01
      • 2017-07-30
      • 2013-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多