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" 和上述属性应该是类似的,但限制应该是指的触摸屏上的意思

对于这两个属性,希望有高人指点下。

这是第一次写文章,有不足之处,大家欢迎指出。

更多相关文章

  1. Android 属性动画(Property Animation) 完全解析【附源码】
  2. ListView的分割线属性操作
  3. Android Application标签属性
  4. Android Studio中drawable下Xml的新建及shape的属性应用
  5. Android:windowSoftInputMode属性说明
  6. Android clipToPadding和clipChildren属性使用

随机推荐

  1. Android之Tab分页标签的实现方法一-----T
  2. Android实践系列之项目基础配置
  3. android手机短信屏蔽
  4. [Unity] 在Unity中导入Android原生插件
  5. android周记1
  6. Android线性布局和相对布局的详解和区别
  7. Android画不规则形状
  8. android 多用户笔记
  9. Android(安卓)ndk开发swig编译jni接口
  10. Android(安卓)入门(7)——文件持久化存储