我View
在一个 android 应用程序中进行了自定义,HorizontalScrollView
如图所示。
<HorizontalScrollView
android:id="@+id/feedBackScroller"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<com.my.views.OfflineFeedbackView
android:id="@+id/feedBackView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/session_rec_page_title_bar_height"
android:layout_marginBottom="@dimen/session_rec_page_ctrl_bar_height"/>
</HorizontalScrollView>
显示OfflineFeedbackView
我正在播放的音轨的音高轨道,我通过scrollTo(newXPos, newYPos)
基于当前播放时间的调用来滚动此视图。我面临的问题是,如果我通过触摸滚动屏幕然后开始播放,滚动的参考似乎在我的视图上发生了变化,并且滚动发生在我通过触摸滚动到的位置。我浏览了 API 文档,发现scrollTo(newXPos, newYPos)
内部调用onScrollChanged(int l, int t, int oldl, int oldt)
whereoldl
和oldt
分别是旧的水平和垂直原点。因此,我对此的解释是,当我通过触摸屏幕滚动时,这些原始值会发生变化。所以,我也试过打电话onScrollChanged(newX, newY, 0, 0)
但这只是冻结屏幕并且没有滚动。难道我做错了什么?还有什么其他更好的方法来处理这个问题?