1
我有一個滾動查看我添加它我的自定義視圖,在customview覆蓋onMeasure & onTouchEvent但當我滾動它什麼都沒有畫。canvas.getHeight等於view.getHeight在平板設備上
protected final void onDraw(Canvas paramCanvas)
{
int text_width;
int yCanvas;
yCanvas = paramCanvas.getClipBounds().top;
int h = paramCanvas.getClipBounds().height() ;
int hView = this.getHeight() ;
int topView = this.getTop();
paramCanvas.drawText("text...yCanvas :"+yCanvas + " --- hCanvas:"+h +"--- hView" + hView + " ----topView"+topView, 20, yCanvas+200, new Paint());
}
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean res = super.onTouchEvent(event);
postInvalidate();
System.out.println("result: " + res);
return res;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int h = 1000;
setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), h);}
有趣的是,在所有的片劑mycanvas高度是可觀看的高度,但在其他裝置canvas.heigh等於()是與喚起注意顯示exactullay相等。
我設置了這個參數,但我沒有回覆。 ( –
也許這個位置是一個問題?或者是你在'onMeasure'中做了些什麼(固定的'1000'看起來很可疑) – Brian
我把它放在位置上( 0)在第一次我的文字畫,但是當我滾動不工作。在模擬器和其他設備(索尼,三星)工作正常,但當我在三星平板電腦(P5100)運行不工作 –