How to achieve two textview of the effect of the horse, if the use of conventional practice, can only make a textview function. The method is now as follows:
1. Add four attributes to TextView
Android:ellipsize= "marquee"
android:focusable= "true"
android:focusableintouchmode= "true"
Android: Singleline= "true"
Implement the TextView class, implement three constructors, and overload the IsFocused method.
public class marqueetext extends textview { public marqueetext (Context context) { super (context); } public MarqueeText (context context, attributeset attrs) { super (
CONTEXT, ATTRS); &NBSP} public marqueetext (context context, attributeset attrs, int
Defstyle) { super (Context, attrs, defstyle) } @Override public boolean isfocused () { return true; } .}
The
uses its own implemented TextView class in the Main.xml file.
This achieves the effect of two horse lights. Here is the main rewrite the Isfocuse method, so that the default two TextView are Focuse, so the two textview can be happy.
Android implements multiple TextView and displays a marquee effect
If you need to display a long copy on a smaller Android page, you cannot display the full, It is natural to think of the marquee--in the TextView effect, but the Android implementation of the marquee effect requires control to get focus, when a control Requestfocus (), the other control will be the focus of the grab, This causes only one control to get the focus at the same time. So, what if you let multiple controls get and hold the focus at the same time? Or, "cheat" the Android system so that it thinks that multiple controls hold the focus, that is, each control is in the focus state.
with the above analysis, the problem translates into how to keep multiple controls in focus at the same time, which requires rewriting some of the TextView methods to "trick" the Android system so that each control requestfocus () after it is in the focus state. And not be deprived of focus, you can reach multiple controls at the same time "hold" the focus, the code is as follows:
Public class marqueetextview extends textview { public Marqueetextview (context context) {
This (context, null);    &NBSP} public marqueetextview (context context, attributeset attrs) {
super (Context, attrs); setfocusable (
true);
setfocusableintouchmode (TRUE); setsingleline (
);
setellipsize (TextUtils.TruncateAt.MARQUEE);
setmarqueerepeatlimit (-1); } public marqueetextview (context context, Attributeset attrs, int defstyle) {
super (Context, attrs, defstyle); setfocusable (
true);
setfocusableintouchmode (TRUE); setsingleline (
);
setellipsize (TextUtils.TruncateAt.MARQUEE);
setmarqueerepeatlimit (-1);    &NBSP} @Override protected void Onfocuschanged (Boolean focused, int direction, rect previouslyfocusedrect) { if (focused) { super.onfocuschanged (Focused, direction,
previouslyfocusedrect);        &NBSP} }
@Override public void onwindowfocuschanged (boolean focused) { if (focused) {
Super.onwindowfocuschanged (focused);        &NBSP} }
@Override public boolean isfocused () { return&nBsp;true;    &NBSP}}
Due to the normal execution of the properties of the marquee:
Android:focusable= "true", android:focusableintouchmode= "true", android:singleline= "true", android:ellipsize= " Marquee
are set in code, you do not need to add these 4 properties when referencing this control.