爱玺玺

爱玺玺的生活日记本。wx:lb87626

创建自定义控件实现滚动

package cn.jianhaozhan.ui;


import android.content.Context;

import android.util.AttributeSet;

import android.view.ViewDebug.ExportedProperty;

import android.widget.TextView;


public class HomeTextView extends TextView {


public HomeTextView(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

// TODO Auto-generated constructor stub

}


public HomeTextView(Context context, AttributeSet attrs) {

super(context, attrs);

// TODO Auto-generated constructor stub

}


public HomeTextView(Context context) {

super(context);

// TODO Auto-generated constructor stub

}

    //是否获取焦点,返回true获取,false不获取。

    @Override

    @ExportedProperty(category = "focus")

    public boolean isFocused() {

    return true;

    }

}


在布局文件中使用自定义控件

    <cn.jianhaozhan.ui.HomeTextView 

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="没有广告没有骚扰,真64杀毒引擎,超神速度,打开7次可以召唤神龙,辅助杀毒!!!"

        android:marqueeRepeatLimit="3"

        android:singleLine="true"

        android:ellipsize="marquee"/>


发表评论:

Powered By Z-BlogPHP 1.4 Deeplue Build 150101

Copyright Your WebSite.Some Rights Reserved.

蜀ICP备11021721号-5