1 XML file
XML file:
<com.example.textviewdemo.marqueetext//Call the custom control and add the package name to the XML file. Class name
Android:id= "@+id/tv1"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:ellipsize= "Marquee"
Android:singline= "true"//single-line display
Android:focusable= "true"
Android:focusableintouchmode= "true"
android:text= "I am a tixeview, I am a tixeview, I am a Tixeview"/>
Java files:
Create a MarqueeText class inheritance TextView
public class MarqueeText extends textview{
Public MarqueeText (context context, AttributeSet attrs, int defstyleattr) {
Super (context, attrs, defstyleattr);
TODO auto-generated Constructor stub
}
Public MarqueeText (context context, AttributeSet Attrs) {
Super (context, attrs);
TODO auto-generated Constructor stub
}
Public MarqueeText (Context context) {
Super (context);
TODO auto-generated Constructor stub
}
@Override
public Boolean isFocused () {//Override this method
TODO auto-generated Method Stub
return true;
}
}
TextView realization of the Marquee effect