我在应用程序中使用 android-wheel http://code.google.com/p/android-wheel/ 。
我的屏幕上有三个并排的轮子。当轮子中的文本比轮子宽时,我希望它滚动到一边(根据选框)
我已经为这些项目实现AbstractWheelTextAdapter
并创建了一个自定义ScrollingTextView
,如下所示:(ScrollingTextView
是为了克服 Marquee 仅在项目具有焦点时工作的问题)
public class ScrollingTextView extends TextView {
public ScrollingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ScrollingTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollingTextView(Context context) {
super(context);
}
@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;
}
}
和xml:
<com.test.app.ScrollingTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "@+id/wheel_text"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:inputType="text"
android:scrollHorizontally="true"
android:textColor="#F000"
android:lines="1"
android:focusable="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"/>
有没有人能让这个工作?
(我也尝试在代码中设置椭圆AbstractWheelTextAdapter
但没有成功)