Android之TextView的跑马灯特效

来源:互联网 发布:在淘宝买散片cpu可靠吗 编辑:程序博客网 时间:2024/04/28 09:45

-----------------转载请注明出处:http://blog.csdn.net/android_cll

一:多话不说,先看看效果图,框起来的地方是可以横着滚动的:


1.xml布局、

<TextView    android:id="@+id/chaoshigonggao"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:layout_centerVertical="true"    android:layout_marginBottom="5dp"    android:layout_marginLeft="10dp"    android:layout_marginRight="5dp"    android:layout_marginTop="5dp"    android:layout_toRightOf="@+id/imggg"    android:text="欢迎光临"    android:textColor="#ffffff"    android:textSize="12dp"    />

2.实现跑马灯的方法、

//跑马灯方法public static void setTextMarquee(TextView textView) {    if (textView != null) {        textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);        textView.setSingleLine(true);        textView.setSelected(true);        textView.setFocusable(true);        textView.setFocusableInTouchMode(true);    }}

3.调用方法实现效果、

private TextView chaoshigonggao;

chaoshigonggao.setText(后台获取的数据);setTextMarquee(chaoshigonggao);

这个效果是不是很简单。。。。。


3 0
原创粉丝点击