现在的位置: 首页 > 综合 > 正文

TextView 实现走马观灯 水平滚动效果

2018年04月01日 ⁄ 综合 ⁄ 共 656字 ⁄ 字号 评论关闭

TextView中设置必须的属性:

1、android:singleLine=true:字体显示为单行;

2、android:marqueeRepeatLimit:设置滚动的次数

3、android:ellipsize:设置字体效果可以是:none,start,moddle,end,走马观灯的属性值为marquee;

4、android:focusableInTouchMode:在触摸模式时,控件是否可以接收焦点

5、android:focusable:Android的缺省行为,是在控件获得Focus时,才会显示走马观灯效果

<TextView 
   android:id="@+id/textDetail"
   android:layout_width="80dp"
   android:layout_height="wrap_content"
            android:paddingLeft="5dp"
           android:paddingRight="5dp"
   android:layout_gravity="center"
   android:singleLine="true"
   android:textColor="#FFFFFF"
android:ellipsize="marquee"
android:focusableInTouchMode="true"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
   
   />

抱歉!评论已关闭.