我正在使用畫(huà)布在 Surface View Camera 上繪制線性布局視圖(插入點(diǎn))。當(dāng)視圖太多時(shí)(例如:在我的情況下為 40),我遇到了一個(gè)問(wèn)題,一些視圖在移動(dòng)相機(jī)時(shí)消失了。我在這里找不到問(wèn)題。setX 和 setY 方法有什么問(wèn)題嗎?你可以在下面看到我的代碼,請(qǐng)回復(fù)它。@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); } }}預(yù)期結(jié)果:所有視圖都應(yīng)出現(xiàn)在相機(jī)視圖中。實(shí)際結(jié)果:一些視圖在移動(dòng) Camera 和 onDrawCanvas 回調(diào)時(shí)消失。我正在使用這個(gè)庫(kù)https://github.com/dat-ng/ar-location-based-android
1 回答

慕工程0101907
TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊
所要做的就是將 LinearLayout 替換為 RelativeLayout,它就像一個(gè)魅力。
添加回答
舉報(bào)
0/150
提交
取消