您的位置:首页 > 移动开发 > Android开发

Android开发textview中跑马灯效果

2011-08-05 10:07 435 查看
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable ="true"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:textSize="24dp"
android:text="@string/hello"
android:background="@drawable/bg"
/>

其中实现跑马灯(学过HTML的 应该清楚Marquee滚动)的关键代码为:

<!--激活焦点-->
android:focusable="true"
<!--单行显示-->
android:singleLine="true"
<!--这里设置为超出文本后滚动显示-->
android:ellipsize="marquee"
<!--这个是设置滚动几次,这里是无限循环-->
android:marqueeRepeatLimit="marquee_forever"
<!--TouchMode模式的焦点激活-->
android:focusableInTouchMode="true"
<!--横向超出后是否有横向滚动条-->
android:scrollHorizontally="true"


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: