真正实现TextView跑马灯效果

 

package com.lewa.launcher.widget.weather;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

public class LewatekWeatherTextView extends TextView {

    public LewatekWeatherTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }


    @Override
    public boolean isFocused() {
//最关键的代码在此
        return true;
    }

    
}


 

最后xml文件中关于TextView必须的3个属性:

android:singleLine="true"

android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"

你可能感兴趣的:(android,xml,Class,Constructor)