我想在中心的相机视图上放置一个叠加作为焦点,它会随着相机的方向移动!
我已经完成了叠加,但它没有进入中心,移动它就消失了!
代码:
public class CrossLayout extends View implements LocationListener, SensorEventListener
{
//...
...//
public void onSensorChanged(SensorEvent evt) {
int type=evt.sensor.getType();
/float vals[] = evt.values;
float localDirection;
if(evt.sensor.getType() == Sensor.TYPE_ORIENTATION)
{
float tmp = vals[0];
tmp += 90;
if(tmp > 360)
tmp -= 360;
direction =(float) ((tmp * (float)0.05) + (direction * (1.0 - (float)0.05)));
/
}
}
public void onDraw(Canvas c)
{
//Log.e("Spec","Updating "+arViews.size()+" views");
//long time = System.currentTimeMillis();
Paint p = new Paint();
p.setColor(Color.WHITE);
c.drawCircle(direction,(float) inclination,10,p);
c.drawText("Compass:"+String.valueOf(direction), 20, 20, p);
c.drawText("Inclination"+String.valueOf(inclination), 150, 20, p);
//Log.e("Spec","Took "+(System.currentTimeMillis() - time)+" seconds");
}
}