• 自定义Textview并对其进行改造,主要目的是让textview获取焦点,这样文字才能滚动起来

    public class MyTextView extends android.support.v7.widget.AppCompatTextView {    public MarqueeTextView(Context context) {        super(context);    }    public MarqueeTextView(Context context, AttributeSet attrs) {        super(context, attrs);    }    public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {        super(context, attrs, defStyle);    }    @Override    public boolean isFocused() {//必须重写,且返回值是true,表示始终获取焦点        return true;    }}
  • xml文件中设置必要属性

    <MyTextView    android:layout_width="match_parent"    android:layout_height="match_parent"    android:ellipsize="marquee" //设置跑马灯效果    android:focusable="true" //需要有焦点才会滚动    android:focusableInTouchMode="true"    android:marqueeRepeatLimit="marquee_forever" //设置循环滚动为无限循环    android:scrollHorizontally="true"    android:singleLine="true" //单行显示   />

更多相关文章

  1. Android 焦点调试
  2. Android借助Application重写App的Crash(简易版)
  3. Android 重写DatePicker------只显示 年-月
  4. Android Studio学习:简单控件:Button控件的点击、长按函数重写
  5. android中动态给EditText获得焦点并弹起键盘的方法
  6. Android 设置Edittext获取焦点并弹出软键盘
  7. 重写gallery 的 BaseAdapter
  8. Android按键音(焦点)

随机推荐

  1. android查看程序运行内存
  2. Android Zxing修改二维码中扫描框的大小
  3. android 程序框架--资源和资产
  4. mac 下配置ANDROID_HOME环境变量
  5. android退出程序 后台运行 实现退出键和h
  6. Android运行时异常“Binary XML file lin
  7. android中在切换fragment时,怎样做到无需
  8. android 开发常用代码备查[更新20150520]
  9. http://www.jb51.net/article/37855.htm
  10. android创建Popwindow弹出菜单的两种方式