自学360之滚动的TextView

来源:互联网 发布:蛙5火箭知乎 编辑:程序博客网 时间:2024/06/05 14:58

滚动的View既字体的滚动循环.

1.android:focusableInTouchMode="true"          //设置是否为滚动

   android:ellipsize="marquee"                             //设置为循环的滚动

但是对于TextView 它默认为False 所以是不可滚动的

所以 写个自定义的类来继承TextView

实现其中的几个方法

写IsFocued 方法 将返回值设置为True

@Override

@ExportedProperty(category = "focus")
public boolean isFocused() {
// TODO Auto-generated method stub
return true;      //欺骗系统
}

2.在实现的XML文件中调用就可以了

 <TextView.MyTextView
        android:focusableInTouchMode="true"
        android:ellipsize="marquee"
        android:id="@+id/tv"
        android:textSize="10dp"
        android:text="我是360卫士我是360卫士我是360卫士我是360卫士我是360卫士我是360卫士我是360卫士我是360卫士我是360卫士我是360卫士11111111111111"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"/>

3.即可实现文字的滚动功能了

0 0
原创粉丝点击