if( grausParaDestino < 0 ){
grausParaDestino = grausParaDestino + 360;
}else if( grausParaDestino > 360 ){
grausParaDestino = grausParaDestino - 360;
}
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
if( anlgeOfView < 1 ){
anlgeOfView = mPreview.getCameraAngleOfView();
}
int larguraDaTela;
if( width > height ){
larguraDaTela = width;
}else{
larguraDaTela = height;
}
double linhaImaginaria = ( larguraDaTela * 360 ) / anlgeOfView;
double posicaoDestinoLinhaImaginaria = ( grausParaDestino * linhaImaginaria ) / 360;
double posicaoPontoAtualLinhaImaginaria = ( graus * linhaImaginaria ) / 360;
double posicaoBalao = posicaoPontoAtualLinhaImaginaria - posicaoDestinoLinhaImaginaria;
double position = Math.round( ( width / 2 ) - posicaoBalao );
layoutParams layoutParams=new LayoutParams(width, height);
layoutParams.height = 50;
layoutParams.width = 50;
layoutParams.setMargins( (int)position, 50, 0, 0);
ImageView balao = (ImageView)findViewById(R.id.balao);
balao.setLayoutParams(layoutParams);
使用此代码,我已将气球定位在屏幕上。感谢所有回复。