首先我们在layout中创建一个xml文件
添加一个TextView 来实现跑马灯效果。
android:focusable="true" //允许TextView获取焦点
android:ellipsize="marquee" //以横向滚动方式显示 要获取焦点之前
android:marqueeRepeatLimit="marquee_forever" //滚动的次数
android:focusableInTouchMode="true" //是否在触摸的模式下获得焦点
android:scrollHorizontally="true" //启动水平滚动条
android:singline="true" //字在一行显示
在TextView中添加这些属性
然后在Java文件中要添加
TextView textView = (TextView)this.findViewById(R.id.textview); //把TextView关联进来
String content="如果天黑之前来得及,我要忘了你的眼睛"; //这是要显示的话语
//设置文本颜色
textView.setTextColor(Color.BLUE);
//设置文本大小
textView.setTextSize(20);
//设置文本显示
添加一个TextView 来实现跑马灯效果。
android:focusable="true" //允许TextView获取焦点
android:ellipsize="marquee" //以横向滚动方式显示 要获取焦点之前
android:marqueeRepeatLimit="marquee_forever" //滚动的次数
android:focusableInTouchMode="true" //是否在触摸的模式下获得焦点
android:scrollHorizontally="true" //启动水平滚动条
android:singline="true" //字在一行显示
在TextView中添加这些属性
然后在Java文件中要添加
TextView textView = (TextView)this.findViewById(R.id.textview); //把TextView关联进来
String content="如果天黑之前来得及,我要忘了你的眼睛"; //这是要显示的话语
//设置文本颜色
textView.setTextColor(Color.BLUE);
//设置文本大小
textView.setTextSize(20);
//设置文本显示
textView.setText(content);