zoukankan      html  css  js  c++  java
  • android 怎么实现跑马灯效果

    自定义控件 FocusedTextView, 使android系统误以为它拥有焦点

     1 public class FocusedTextView extends TextView {
     2     public FocusedTextView(Context context, AttributeSet attrs, int defStyle) {
     3         super(context, attrs, defStyle);
     4         // TODO Auto-generated constructor stub
     5     }
     6     public FocusedTextView(Context context, AttributeSet attrs) {
     7         super(context, attrs);
     8         // TODO Auto-generated constructor stub
     9     }
    10     public FocusedTextView(Context context) {
    11         super(context);
    12         // TODO Auto-generated constructor stub
    13     }
    14     @ExportedProperty(category = "focus")
    15     public boolean isFocused() {  //永远拥有焦点
    16         // TODO Auto-generated method stub
    17         return true;
    18     }
    19 }

    xml布局中使用此控件

    1 <com.test.ui.FocusedTextView
    2 android:id="@+id/tv_marquee"
    3 android:layout_width="match_parent"
    4 android:layout_height="wrap_content"
    5 android:singleLine="true"
    6 android:ellipsize="marquee"
    7 android:text="跑马灯效果!跑马灯效果!跑马灯效果!跑马灯效果!跑马灯效果!跑马灯效果!跑马灯效果!跑马灯效果!"
    8 android:textSize="30dp" />
  • 相关阅读:
    npm命令
    前端单元测试工具karma和jest
    加解密学习之--模运算与经典密码学
    数据结构之-翻转二叉树
    数据结构之-链表倒转
    转载:MQ
    分布式ID生成器 待整理
    软件开发中的负载均衡
    制作软件过程中所产出的文档(请补充)
    多线程的创建
  • 原文地址:https://www.cnblogs.com/superPerfect/p/4217091.html
Copyright © 2011-2022 走看看