我正在使用画布在 Surface View Camera 上绘制线性布局视图(插入点)。当视图太多时(例如:在我的情况下为 40),我遇到了一个问题,一些视图在移动相机时消失了。我在这里找不到问题。setX 和 setY 方法有什么问题吗?你可以在下面看到我的代码,请回复它。@Overrideprotected void onDraw(Canvas canvas) { super.onDraw(canvas); if (currentLocation == null) { return; } for (int i = 0; i < places.size(); i++) { float[] currentLocationInECEF = LocationHelper.WSG84toECEF(currentLocation); float[] pointInECEF = LocationHelper.WSG84toECEF(poiLoc.get(i)); float[] pointInENU = LocationHelper.ECEFtoENU(currentLocation, currentLocationInECEF, pointInECEF); Matrix.multiplyMV(cameraCoordinateVector, 0, rotatedProjectionMatrix, 0, pointInENU, 0); if (cameraCoordinateVector[2] < 0 && insertPoint!=null && insertPoint.getChildAt(i)!=null) { float x = (0.5f + cameraCoordinateVector[0] / cameraCoordinateVector[3]) * canvas.getWidth(); float y = (0.5f - cameraCoordinateVector[1] / cameraCoordinateVector[3]) * canvas.getHeight(); insertPoint.getChildAt(i).setX(x - (insertPoint.getChildAt(i).getWidth()/2)); insertPoint.getChildAt(i).setY(y); insertPoint.getChildAt(i).setVisibility(VISIBLE); } }}预期结果:所有视图都应出现在相机视图中。实际结果:一些视图在移动 Camera 和 onDrawCanvas 回调时消失。我正在使用这个库https://github.com/dat-ng/ar-location-based-android
添加回答
举报
0/150
提交
取消