SurfaceView setMeasuredDimension() with height greater than 4096 crashes

324 Views Asked by At

I'm using surfaceview in my work. My requirement is to make a curved line in a vertical scrollview. When I test it I found when the height is less than 4096 it works well, but more than that (even just 4097), it crashes!

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // TODO Auto-generated method stub
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 4097);
}

Can anyone tell me why?

1

There are 1 best solutions below

2
daemmie On

The reason might me the max supported texture size of your device.

Which seem to be 4096 in your case.You should not use bigger values for your surface.

Take a look at: How can I find the maximum texture size for different phones?

to find what texture sizes are supported