カスタムビューがあり、この投稿を使用してスクロールバーを有効にすることができました:Android:キャンバスベースのビューでスクロールバーを有効にします。問題は、計算関数を上書きしても、スクロールできないことです。ビューを作成するコードは次のとおりです。
final PaintBoardView paintBoardView=new PaintBoardView(this);
LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(
0,ViewGroup.LayoutParams.FILL_PARENT,(float)0.8);
paintBoardView.setLayoutParams(layoutParams);
ViewGroup boardToolsContainer=(ViewGroup)findViewById(R.id.board_tools_container);
boardToolsContainer.addView(paintBoardView);
そして、これがビューのコンストラクターです。
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; }
言ったように、スクロールバーが表示されますが、スクロールが機能していません。助けてくれてありがとう。