直接在布局里写代码就好了:
<TextView
android:id="@+id/menu_desc"
android:layout_width="300dip"
android:layout_height="wrap_content"
android:text="温馨提示:左右滑动更改菜单,点击进入"
android:textColor="@color/white"
android:textSize="22dip"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
>
</TextView>
主要是这几行:
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
参考: Android实现跑马灯效果