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" />
  • 相关阅读:
    一个前端框架应该有的一些公共函数
    前端开发避免bug注意事项
    angular中iframe的ng-src属性
    jquery上传base64位图片
    [Luogu]P2302 loidc,跑起来
    情书
    SA学习笔记
    关于GCD的证明
    文本生成器(AC自动机 + DP)
    AC自动机--速成版
  • 原文地址:https://www.cnblogs.com/superPerfect/p/4217091.html
Copyright © 2011-2022 走看看