【问题标题】:vertically automatic scroll text of textview with specific time interval in android在android中具有特定时间间隔的textview垂直自动滚动文本
【发布时间】:2012-10-02 15:36:02
【问题描述】:

我是 android 的初学者。在我的应用程序中,我的 textview 有多行文本,它可能有 15-20 行。我想要该文本视图中文本的垂直自动滚动。那么解决方案是什么?

这是我的 xml 代码:

<LinearLayout 
    android:id="@+id/Thumbnail"
    android:layout_width="fill_parent"
    android:layout_height="200dp"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"
    android:gravity="center"
    android:background="@drawable/imgres">
    <ScrollView      
        android:id="@+id/sv"     
        android:layout_width="fill_parent"     
        android:layout_height="fill_parent"    
        android:fillViewport="true" >

    <TextView 
    android:id="@+id/tv"
    android:layout_width="fill_parent"
    android:layout_height="200dp"
    android:background="#80000000"
    android:width="200dp"
    android:textStyle="bold"
    android:textColor="#ffffff"
    android:gravity="center"
    android:layout_alignParentTop="true" 
    android:focusable="true"
    android:focusableInTouchMode="true" 
    android:scrollbars = "vertical"
    android:maxLines="10"
    />    
   </ScrollView>
</LinearLayout>

在函数中,我使用下面的代码设置了我的 textview 的文本:

tv.setText(textArray);

【问题讨论】:

标签: android timer scroll textview scrollview


【解决方案1】:

您实际上不需要使用 ScrollView。

只需设置

android:maxLines = "AN_INTEGER_NUMBER"

android:scrollbars = "vertical"

布局的 xml 文件中 TextView 的属性。

然后使用:

yourTextView.setMovementMethod(new ScrollingMovementMethod())

在您的代码中。

【讨论】:

  • 是的,这段代码运行良好。但我想实现特定时间间隔的自动滚动。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-01-04
  • 1970-01-01
  • 1970-01-01
  • 2014-04-01
  • 2012-02-14
  • 2016-10-06
  • 1970-01-01
相关资源
最近更新 更多