5分钟实现Android手机下的指南针应用

5分钟实现Android手机上的指南针应用

继续研究国内的Android应用开发平台Rexsee,看了社区上开放的API说明与源码,尝试做个Android的指南针应用,很快、很强大。

Rexsee社区的地址,全部开源,可以去下载查看:http://www.rexsee.com/

 

<!--[if !supportLists]-->1.       <!--[endif]-->首先找两个好看的图片,一个罗盘,一个背景;

<!--[if !supportLists]-->2.       <!--[endif]-->打开传感器rexseeOrientation.start()

<!--[if !supportLists]-->3.       <!--[endif]-->把方向改变时触发的事件写上:

function onOrientationChanged(){   //方向传感器事件,即当方向发生改变时触发的动作
  var x = rexseeOrientation.getLastKnownX();
  x = 90 - x;
  document.getElementById('oriDiv').style.webkitTransform = 'rotate('+x+"deg)";
}
 

<!--[if !supportLists]-->4.       <!--[endif]-->然后是处理图片,位置一定要调整好

<div id='Layer1'>
  <div id="northDiv"><img src="img/north.png" width="300" height="300" /></div>
  <div id="oriDiv"><img src="img/compass.png" width="260" height="260" /></div>
</div>
 

 

呵呵,确实没看错,就是用的HTML写的Android移动应用哈。。Rexsee就是一个移动Web开发平台,使用Web开发就是可以搞定。

可以看看我的原帖:http://www.rexsee.com/CN/bbs/thread/2011-10-09/78.html