这个自定义视图应该继承android.support.v7.widget.AppCompatTextView,我是这样写的成功,不过在eclipse下的。package com.example.studyandroid;import android.content.Context;import android.util.AttributeSet;import android.widget.TextView;public class Marquee extends TextView {public Marquee(Context context) {super(context);// TODO Auto-generated constructor stub}public Marquee(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);// TODO Auto-generated constructor stub}public Marquee(Context context, AttributeSet attrs) {super(context, attrs);// TODO Auto-generated constructor stub}@Overridepublic boolean isFocused() {return true;}}
你要不在extends 后改成 AppCompatTextView ,导入android.support.v7.widget.AppCompatTextView