Android 跑马灯效果是通过TextView来实现的,前提是TextView显示的内容必须比TextView控件分配的宽度宽,并且保证TextView里面的内容是单行显示,然后通过TextView的 ellipsize="marquee" 来设置跑马灯效果
效果图:
[img]http://dl.iteye.com/upload/attachment/416419/9441cd4d-0044-3e88-9cc6-cf2854e01f7c.png[/img]
代码:
效果图:
[img]http://dl.iteye.com/upload/attachment/416419/9441cd4d-0044-3e88-9cc6-cf2854e01f7c.png[/img]
代码:
<?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"
>
<!-- singleLine="true":单行显示 scrollHorizontally="true":水平滚动
marqueeRepeatLimit="marquee_forever":重复次数 ,可设置整型值 ellipsize="marquee":滚动-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:textSize="18dip"
android:textColor="@android:color/white"
android:text="开放平台成网络淘金下一站 从圈地到吸纳盟友,除腾讯外,百度、盛大、京东商城等互联网行业标杆目前都已推出了各自的开放平台。"
/>
</LinearLayout>