我有一个CustomScrollView
扩展ScrollView
,然后我在方法中做一些事情OnDraw()
。不幸的是,CustomScrollView
不能再滚动了,这是我所做的代码。
@Override
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
Log.d(null,"current measured height is:"+getMeasuredHeight());
Log.d(null,"screen height is:"+mScreenHeight);
Rect rect=new Rect(50,0,mScreenWidth-50,mScreenHeight<<1);
canvas.drawRect(rect,mFilledPaint);
}
@Override
public void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
super.onMeasure(widthMeasureSpec,heightMeasureSpec);
setMeasuredDimension((int)mScreenWidth,(int)mScreenHeight<<1);
}
private void init(){
mFilledPaint.setStyle(Paint.Style.FILL);
mFilledPaint.setColor(Color.WHITE);
mScreenWidth=((Activity)mContext).getWindowManager().getDefaultDisplay().getWidth();
mScreenHeight=((Activity)mContext).getWindowManager().getDefaultDisplay().getHeight();
}