垂直自动滚动的TextView [英] Vertically AutoScrolling Textview

查看:133
本文介绍了垂直自动滚动的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是希望建立一个简单的TextView包装在一个滚动型它会自动向下滚动显示以同样的方式TextView的内容如电影都显示他们的学分。我不希望用户必须与滚动条互动。有没有按钮或其它的布局,我在屏幕上工作,所以学分填满整个屏幕。

我在我的应用程序水平滚动的TextView的,我安装使用选取框这是pretty的易XML,但我不能确定的最简单的方法让我的文字垂直滚动。这是XML code,我与我将需要在Java端约code到得到这个工作的工作?在此先感谢!

 <滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:ID =@ + ID / SV
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:fillViewport =真正的>

<的TextView
机器人:ID =@ + ID /电视
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/ credits_text
机器人:layout_alignParentTop =真
机器人:可聚焦=真
机器人:focusableInTouchMode =真/>
< /滚动型>
 

解决方案

这是我做在一个水平滚动的方式。它拥有2秒,滚动视图每20毫秒

 公共无效scrollRight(最终Horizo​​ntalScrollView高){
新CountDownTimer(2000,20){

    公共无效onTick(长millisUntilFinished){
        h.scrollTo((int)的(2000  -  millisUntilFinished),0);
    }

    公共无效onFinish(){

    }
 }。开始(); }
 

h是我Horizo​​ntalScrollView

I'm just looking to setup a simple TextView wrapped in a ScrollView which will automatically scroll down displaying the contents of the TextView in the same way as movies have their credits displayed. I do not want the user to have to interact with scroll bars. There are no buttons or other layouts I am working with on the screen so the credits fills the whole screen.

I have in my app a horizontally scrolling TextView which I setup in XML using marquee which was pretty easy but I am unsure of the easiest approach to have my text scroll vertically. This is the XML code I am working with will I need to have some code on the Java side to get this to work? Thanks in advance!

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"     
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="wrap_content"
android:layout_height="wrap_content"
android:text="@string/credits_text"
android:layout_alignParentTop="true"       
android:focusable="true"     
android:focusableInTouchMode="true"/> 
</ScrollView> 

解决方案

This is the way I am doing it in a horizontal scroll. It is set on 2 seconds and scrolls the view every 20 miliseconds

    public void scrollRight(final HorizontalScrollView h){
new CountDownTimer(2000, 20) { 

    public void onTick(long millisUntilFinished) { 
        h.scrollTo((int) (2000 - millisUntilFinished), 0); 
    } 

    public void onFinish() { 

    } 
 }.start(); }

h is my HorizontalScrollView

这篇关于垂直自动滚动的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆