zoukankan      html  css  js  c++  java
  • 它们的定义TextView使之具有跑马灯的效果

    一、引入问题
    使用通用textview快乐效应,焦点事件不启动滚动,button目前的焦点事件,但丑,因此,需要定制TextView 天生焦点

    个textview
    FocusedTextView.java

    package com.xuliugen.mobilesafe.ui;
    
    import android.content.Context;
    import android.util.AttributeSet;
    import android.view.ViewDebug.ExportedProperty;
    import android.widget.TextView;
    
    /**
     * 跑马的效果。一開始没有焦点事件不会进行滚动
     * 
     * button有焦点事件。可是比較难看。因此须要自定一个TextView 一出生就有焦点
     * 
     * @author xuliugen
     * 
     */
    public class FocusedTextView extends TextView {
    
        /**
         * 自己定义的view须要下面几个构造方法
         * 
         * @param context
         * @param attrs
         * @param defStyle
         */
        public FocusedTextView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        public FocusedTextView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public FocusedTextView(Context context) {
            super(context);
        }
    
        /**
         * 当前并没有焦点。我仅仅是欺骗了Android系统
         */
        @Override
        @ExportedProperty(category = "focus")
        public boolean isFocused() {
            return true;
        }
    }
    

    那么我们引用的时候例如以下:

     <!-- 跑马灯的效果 :滚动的textView-->
    
        <com.xuliugen.mobilesafe.ui.FocusedTextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:singleLine="true"
            android:text="自己定义TextView使之具有跑马灯的效果自己定义TextView使之具有跑马灯的效果自己定义TextView使之具有跑马灯的效果"
            android:textSize="18sp" />

    版权声明:本文博主原创文章。博客,未经同意不得转载。

  • 相关阅读:
    堆得简单介绍以及堆排序
    从交换两个变量的值来看程序员的“奇技淫巧”
    两道有意思的题目
    mac上使用brew
    安全考虑,binlog_row_image建议尽量使用FULL
    Python3.6新特性
    自动化测试基础篇--Selenium浏览器操作
    自动化测试基础篇--Selenium Xpath定位
    自动化测试基础篇--Selenium元素定位
    自动化测试基础篇--Selenium Python环境搭建
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4832150.html
Copyright © 2011-2022 走看看