1. 对于需要文本显示的内容过多的时候,需要滚动显示

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:layout_width="fill_parent"

android:layout_height="80dp"

android:fadeScrollbars="false"

android:scrollbarAlwaysDrawVerticalTrack="true"

android:scrollbars="vertical" >

android:layout_width="fill_parent"

android:layout_height="wrap_content" >

android:id="@+id/tv"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="@android:color/black"

android:scrollbars="vertical"

android:text="@string/hello_world" />

2.对于需要实现跑马灯似的,自动滚动的,这里是看了github上一个国外的程序员自定义的一个textview

package cn.steve.slidetextview;

import android.content.Context;

import android.util.AttributeSet;

import android.view.animation.LinearInterpolator;

import android.widget.Scroller;

import android.widget.TextView;

/**

* A TextView that scrolls it contents across the screen, in a similar fashion

* as movie credits roll across the theater screen.

*

* @author Matthias Kaeppler

*

*/

public class ScrollingTextView extends TextView implements Runnable {

private static final float DEFAULT_SPEED = 15.0f;

private Scroller scroller;

private float speed = DEFAULT_SPEED;

private boolean continuousScrolling = true;

public ScrollingTextView(Context context) {

super(context);

setup(context);

}

public ScrollingTextView(Context context, AttributeSet attributes) {

super(context, attributes);

setup(context);

}

private void setup(Context context) {

scroller = new Scroller(context, new LinearInterpolator());

setScroller(scroller);

}

@Override

protected void onLayout(boolean changed, int left, int top, int right,

int bottom) {

super.onLayout(changed, left, top, right, bottom);

if (scroller.isFinished()) {

scroll();

}

}

private void scroll() {

int viewHeight = getHeight();

int visibleHeight = viewHeight - getPaddingBottom() - getPaddingTop();

int lineHeight = getLineHeight();

int offset = -1 * visibleHeight;

int distance = visibleHeight + getLineCount() * lineHeight;

int duration = (int) (distance * speed);

scroller.startScroll(0, offset, 0, distance, duration);

if (continuousScrolling) {

post(this);

}

}

@Override

public void run() {

if (scroller.isFinished()) {

scroll();

} else {

post(this);

}

}

public void setSpeed(float speed) {

this.speed = speed;

}

public float getSpeed() {

return speed;

}

public void setContinuousScrolling(boolean continuousScrolling) {

this.continuousScrolling = continuousScrolling;

}

public boolean isContinuousScrolling() {

return continuousScrolling;

}

}

android 文本滚动显示,Android 文本内容滚动显示相关推荐

  1. shell 密码输入不显示,Shell输出内容不显示密码,Shell实现有密码自动登录sshpass 应用实践...

    在很多实践项目中,我们经常会通过SSH来进行认证,如通过SSH拷贝文件,虽然我们可以使用公钥与私钥实现ssh 无密码登录,在不同的服务器上又需要配对相应的密钥,切换用户麻烦等问题,在一些需要交互但会涉 ...

  2. android开发文字滚动代码,android实现滚动文本效果

    本文实例为大家分享了android实现滚动文本效果的具体代码,供大家参考,具体内容如下 效果图 实现方法 直接上代码 首先是一个自定义layout,继承自FrameLayout public clas ...

  3. android 写空指针,写下文本内容时bufferedwriter一直显示空指针,求指教

    写入文本内容时bufferedwriter一直显示空指针,求指教 package com.example.android_32_chatclinet; import java.io.BufferedR ...

  4. android基础知识学习(1) TextView属性大全+单行显示长文本

    android:autoLink 设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接.可选值(none/web/email/phone/map/all)  androi ...

  5. android 自定义文字位置,Android设置显示文本

    如果不设置singleLine或者设置为false,文本将自动换行, android:text设置显示文本. android:textAppearance设置文字外观.如 "android: ...

  6. android文字多行滚动显示,Android TextView多行文本滚动实现

    Android中我们为了实现文本的滚动可以在ScrollView中嵌入一个TextView,其实TextView自己也可以实现多行滚动的,毕竟ScrollView必须只能有一个直接的子类布局.只要在l ...

  7. Android之ScrollView滚动布局控件使用以及显示新闻网页

    ScrollView滚动布局使用原理: ①滚动产生的条件是,里面的内容大于物理尺寸 ②ScrollView里面只有一个子元素,这个子元素就是一个线性布局LinearLayout,我们可以在线性布局中添 ...

  8. android ExpandableTextView-自定义可以动态展开/收缩显示长文本的TextView

    前言: 为了保持界面UI的整洁以及将尽可能多的内容显示在有限的空间中,往往需要将长度过长的TextView进行内容截取.本控件满足了TextView可在"完整内容"与"截 ...

  9. android 文字选中朗读,Android开发之文本内容自动朗读功能实现方法

    本文实例讲述了Android开发之文本内容自动朗读功能实现方法.分享给大家供大家参考,具体如下: Android提供了自动朗读支持.自动朗读支持可以对指定文本内容进行朗读,从而发生声音:不仅如此,An ...

  10. android 文本分页显示,Android查看带有列表视图的分页器并动态添加文本

    我在一个分片活动中有一个Viewpager,它有一个带有编辑文本和发送按钮的botton框架. 在片段布局中,我有一个ListView,并在片段中附加了一个适配器.现在我正在实现从片段中的Parent ...

最新文章

  1. python中*args 与 **kwargs形式的参数的用法详解
  2. Java SE 6 新特性: 编译器 API
  3. c语言格式化字符漏洞,格式化字符串漏洞题目练习
  4. scrapy 第一个案例(爬取腾讯招聘职位信息)
  5. cmake构建工具 初步01
  6. Mysql索引优化实例讲解
  7. [fzu 2273]判断两个三角形的位置关系
  8. Noip2016day2
  9. 记录一些关于操作数据库(本地和linux服务器)常用的命令
  10. 《C语言及程序设计》实践参考——太乐了
  11. linux awk数组使用
  12. 张锋因何错过诺贝尔化学奖?
  13. 企业级应用软件开发面临的困境
  14. SD卡bus speed-Default speed/Default high speed/UHS-1/UHS-2/UHS-3
  15. 实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- 被监控端
  16. 基于RTSP视频流的Java后台服务端虹软人脸识别
  17. 商城App接入快递100
  18. netty内存泄露检测
  19. 服务器支持电脑硬盘吗,服务器硬盘和普通硬盘有什么区别?服务器硬盘和普通硬盘区别对比评测...
  20. Java JDK 控制台环境设置

热门文章

  1. 2018.06.06 第二天面试人在囧途跑错了地方
  2. SQL right()函数
  3. Blast 几种方法的具体用法以及含义
  4. 宇宙无敌第一IED Visual studio 常用快捷键使用
  5. 小程序之视频卡顿问题
  6. 英语海报简笔php匹配img画,简单英语海报图片手绘,一年级英语海报图片 手绘?...
  7. python3字符串详解速查,新手流泪,老手顿悟
  8. 计算机学后感作文400,考试后的感想作文400字(精选10篇)
  9. 深入浅出TensorFlow2函数——tf.data.Dataset.shuffle
  10. dcdc低压升压直流稳压高压负电压输出12v24v转-50V100V110V150V200V250V300V350V400V500V