Android实现跑马灯效果的方法

2019-12-10 19:59:08丽君

易采站长站为您分析Android实现跑马灯效果的方法,通过页面XML布局设置实现带有跑马灯效果的文字滚动显示功能,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了Android实现跑马灯效果的方法。。具体如下:

运行效果截图如下:

Android实现跑马灯效果的方法

Android实现跑马灯效果的方法

直接在布局里写代码就好了:

 

 
  1. <TextView  android:id="@+id/menu_desc" 
  2. android:layout_width="300dip"  android:layout_height="wrap_content" 
  3. android:text="温馨提示:左右滑动更改菜单,点击进入"  android:textColor="@color/white" 
  4. android:textSize="22dip"  android:singleLine="true" 
  5. android:ellipsize="marquee"  android:focusable="true" 
  6. android:focusableInTouchMode="true"  android:scrollHorizontally="true" 
  7. android:marqueeRepeatLimit="marquee_forever"  android:layout_centerHorizontal="true" 
  8. android:layout_centerVertical="true"  > 
  9. </TextView> 

主要是这几行:

android:singleLine="true"

android:ellipsize="marquee"

android:focusable="true"