Android TextView滚动效果

觉得字符串可能长短不一,

不能完全显示,

老大说让做成滚动效果那种,

本来以为很难,

过万能的

baidu

告诉我不难,如下而已:

 

TextView

加三行属性

 

 

android:singleLine="true" 

 

android:ellipsize="marquee" 

 

android:marqueeRepeatLimit="marquee_forever" 

 

 

ps

:下面这个

layout

我验证过,可以滚动的

 

 

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

android:orientation="vertical" 

android:layout_width="fill_parent" 

android:layout_height="fill_parent" 

<TextView    

    

android:text="123456789qwertyuiopasdghhj123456789qwertyuiopasdgh

hj" 

android:layout_width="wrap_content" 

android:layout_height="wrap_content" 

android:singleLine="true" 

android:ellipsize="marquee" 

android:marqueeRepeatLimit="marquee_forever" 

android:focusable="true"/>    

    

 

</LinearLayout> 

 

layout

实现代码是:

 

本篇文章来源于

 

Linux

公社网站

(www.linuxidc.com) 

 

原文链接:

http://www.linuxidc.com/Linux/2011-04/34225.htm 

<ScrollViewxmlns:Android="http://schemas.android.com/apk/res/android" 

 

 

 

 

 

 

 

 

 

Android:layout_width="fill_parent" android:layout_height="fill_parent" 

 

 

 

 

 

 

 

 

 

Android:scrollbars="vertical" android:fadingEdge="vertical"> 

 

 

 

 

 

 

 

 

 

<TextView Android:layout_width="fill_parent" 

 

 

 

 

 

 

 

 

 

 

 

 

 

Android:layout_height="wrap_content" android:id="@+id/description1" 

 

 

 

 

 

 

 

 

 

 

 

 

 

Android:textColor="#071907" android:paddingTop="5dip" /> 

 

 

 

 

 

</ScrollView> 

 

 

 

本篇文章来源于

 

Linux

公社网站

(www.linuxidc.com) 

 

原文链接:

http://www.linuxidc.com/Linux/2011-04/34225.htm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值