android_跑马灯
android:id="@+id/tv12" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:text="跑马灯效果 学好android开发就关注公众号 android开发666 经常推送原创文章"/>
其中有几个问题是我自己碰到的,列举如下:
1.宽度android:layout_width不可以设置为wrap_content(自适应内容)
2.android:text最好是比较长的字符串,最少要长过自己设置的width大小
3.颜色最好别设置为@android:color/white,否则你什么都看不到,因为背景颜色也是white
4.在xml中,TextView 的属性
android:ellipsize = "end" 省略号在结尾
android:ellipsize = "start" 省略号在开头
android:ellipsize = "middle" 省略号在中间
android:ellipsize = "marquee" 跑马灯
5.android:scrollHorizontally="true"水平滚动
6.android:marqueeRepeatLimit="marquee_forever" 无限次循环
7.最后还有两句代码没有解释:
android:focusable="true" //让TextView获得焦点 android:focusableInTouchMode="true" //针对触摸屏获得当前焦点
事实上这两句代码我也了解不是特别多,在网上查了下这两个属性,目前理解为:
android:focusable="true" 相当于当前Activity打开的时候,让当前控件TextView获得焦点,才可以实现滚动功能
android:focusableInTouchMode="true" 和上述属性应该是类似的,但限制应该是指的触摸屏上的意思
对于这两个属性,希望有高人指点下。
这是第一次写文章,有不足之处,大家欢迎指出。
更多相关文章
- Android 属性动画(Property Animation) 完全解析【附源码】
- ListView的分割线属性操作
- Android Application标签属性
- Android Studio中drawable下Xml的新建及shape的属性应用
- Android:windowSoftInputMode属性说明
- Android clipToPadding和clipChildren属性使用