我想在我的应用中使用2个marquees,但只有一个一直在工作。但是只有一个一直在工作。如果我注释第一个,那么第二个就会工作。否则第一个就会工作。或者说一次只有一个标记得到焦点。如果我们按下箭头,那么第二个将得到焦点。如何让这两个牌子都得到焦点?
我如何才能同时显示2个标志牌呢?
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/imgLogotb">
<TextView
android:id="@+id/txt1"
android:layout_width="wrap_content"
android:text="START | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | lunch 20.00 | Dinner 60.00 | Travel 60.00 | Doctor 5000.00 | END"
android:layout_height="20dip"
android:singleLine="false"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true">
</TextView>
<TextView
android:id="@+id/txt2"
android:layout_width="wrap_content"
android:text="START | lunch 1.00 | Dinner 2.00 | Travel 3.00 | Doctor 4.00 | lunch 5.00 | Dinner 6.00 | Travel 7.00 | Doctor 8.00 | END"
android:layout_height="20dip"
android:singleLine="false"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true">
</TextView>
</RelativeLayout>
请帮助我给出解决方案......谢谢......。
现在,我找到了一个补丁,你可以说,为我自己。现在我们的目标是让每个文本视图同时获得焦点。
现在我们的目标是同时将焦点放在每个文本视图上,为此我们将创建我们自己的自定义TextView组件类,并在方法isFocusable()中返回总是true。这就是了。
public class ScrollingTextView extends TextView {
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if(focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
现在你要做的就是把这个TextView添加到你的XML布局中,如下所示。
<com.yourpackagename.ScrollingTextView
android:text="LONG LONG LONG LONG text..................."
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:id="@+id/TextView03"
android:padding="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
这就完成了,你可以在XML布局中任意添加这个TextView组件,而且所有的TextView都会同时marquee。