2012-06-01 132 views
0

我有一個自定義視圖,我設法使用這個帖子啓用滾動條:Android: Enable Scrollbars on Canvas-Based View。 問題是我無法滾動它們,即使我覆蓋了計算功能。 下面是創建視圖代碼:自定義視圖滾動條

​​

而這裏的視圖的構造函數:

super(context); 
setBackgroundResource(android.R.color.white); 
setHorizontalScrollBarEnabled(true); 
setVerticalScrollBarEnabled(true); 
TypedArray styledAttributes=context.obtainStyledAttributes(
    R.styleable.View); 
initializeScrollbars(styledAttributes); 
styledAttributes.recycle(); 

和:

@Override public int computeHorizontalScrollRange() { return 2000; } 
@Override public int computeVerticalScrollRange() { return 2000; } 

正如我所說的,我看到滾動條,但滾動不起作用。 感謝您的幫助。

回答

0

最後,我只是使用視圖的scrollBy和scrollTo方法在onTouchEvent函數中滾動自己。