Android的TextView的滚动 [英] Android TextView Scrollable

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

问题描述

我有一个TextView其大小为16个字符,如果超过16个字符,我想打
它可滚动到用户查看剩余字符
可以在任何一个可以帮助

我已经试过此链接 Android中制作的TextView滚动

但没有结果呢?

我的TextView的布局:

 <的TextView
    机器人:ID =@ + ID / TV1
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:最大长度=16
       机器人:滚动条=垂直
       机器人:ellipsize =结束
    机器人:文字=fdgdddhhhdhd
    />


解决方案

在你的XML布局文件:

 <的TextView
    机器人:ID =@ + ID / message_scroll
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:滚动条=垂直
    机器人:文字=@字符串/ LOREM/>

在Java类文件:

  TextView的电视=(TextView中)rootView.findViewById(R.id.message_scroll);
tv.setMovementMethod(新ScrollingMovementMethod());

I have a textview which size is 16 characters,If it exceeds 16 characters i want to make it scrollable to the user to view remaining characters Could any one help

I have tried this link Making TextView Scrollable in Android

But there is no result?

My TextView Layout:

<TextView  
    android:id="@+id/tv1"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:maxLength="16"
       android:scrollbars = "vertical"
       android:ellipsize="end"
    android:text="fdgdddhhhdhd"
    />

解决方案

In your XML layout file:

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

In your Java class file:

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

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

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