zoukankan      html  css  js  c++  java
  • 一个页面多个TextView跑马灯,与焦点无关

    package com.travelsky.bluesky.utils;
    
    import android.content.Context;
    import android.graphics.Rect;
    import android.text.TextUtils;
    import android.util.AttributeSet;
    import android.widget.TextView;
    
    /**
     * 跑马灯效果 textview                              
     * @author  zbtu
     * @date    2013-4-22 上午8:55:44                                                              
     */
    public class MarqueeTextView extends TextView
    {
        public MarqueeTextView(Context context)
        {
            this(context, null);
        }
        
        public MarqueeTextView(Context context, AttributeSet attrs)
        {
            super(context, attrs);
            
            setFocusable(true);
            setFocusableInTouchMode(true);
            
            setSingleLine();
            setEllipsize(TextUtils.TruncateAt.MARQUEE);
            setMarqueeRepeatLimit(-1);
        }
        
        public MarqueeTextView(Context context, AttributeSet attrs, int defStyle)
        {
            super(context, attrs, defStyle);
            
            setFocusable(true);
            setFocusableInTouchMode(true);
            
            setSingleLine();
            setEllipsize(TextUtils.TruncateAt.MARQUEE);
            setMarqueeRepeatLimit(-1);
        }
    
        @Override
        protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
        {
            if (focused)
            {
                super.onFocusChanged(focused, direction, previouslyFocusedRect);
            }
        }
        
        @Override
        public void onWindowFocusChanged(boolean focused)
        {
            if (focused)
            {
                super.onWindowFocusChanged(focused);
            }
        }
        
        @Override
        public boolean isFocused()
        {
            return true;
        }
    }

    因为已经做了焦点等处理,所以不用再配置

    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:gravity="center_vertical"
    android:marqueeRepeatLimit="marquee_forever"

    直接引用即可

  • 相关阅读:
    mininet 多径传输网络仿真
    mininet 多径仿真双路由双网卡
    mininet仿真星型拓扑
    mininet 三个路由器两个终端的仿真
    mininet 两个路由器两个终端仿真
    mininet 仿真一个路由器两个终端
    mininet 两个交换机两个终端的仿真
    mininet 一个交换机两个终端的仿真
    ps命令
    df命令
  • 原文地址:https://www.cnblogs.com/anee/p/3039959.html
Copyright © 2011-2022 走看看