求助做过安卓手电筒的各位大神 安卓随手电筒 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个 我感觉可以 自己手动画一个VIEW 然后做一下手势监听每次监听到就 重绘制下。在具体的我也没法说了(没做过),大体上感觉是这样的! 用view画,添加监听事件,然后重绘一下。 需要你计算触控点,来实时旋转画布,canvas的rotate , 手电筒,呵呵,刚刚看到苹果的APP审查原则:2.1 崩溃的程序将会被拒绝。2.2 存在错误的程序将会被拒绝。2.11 与App Store已有程序重复的应用可能会被拒绝,特别是数量很多的情况下,比如手电筒应用和爱经应用。 首先,非常感谢各位的热心帮助。我已经做了一些,但旋转角度老有问题,现贴上代码,求指导public class MyView extends View { private Bitmap bmp; //旋转指针图片 private Bitmap bmpCenter; //中心的开关按钮图片 private Bitmap bmpOuter; //旋转指针图片对应的旋转刻度图片 //开关按钮中心点坐标 private float centerX; private float centerY; //起始触摸点坐标 private float downX; private float downY; private Matrix mtx; private float rotateAngle; //旋转角度 private boolean isTouch; //判断触摸点是否在旋转指针图片上 public MyView(Context ctt, float x, float y) { super(ctt); bmp = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_rotating)).getBitmap(); bmpCenter = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_flashlight_switch_close)).getBitmap(); bmpOuter = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_scale_bg)).getBitmap(); centerX = x; centerY = y; downX = 0; downY = 0; isTouch = false; mtx = new Matrix(); } @Override public void onDraw(Canvas cvs) { super.onDraw(cvs); cvs.drawBitmap(bmpCenter, centerX-bmpCenter.getWidth()/2, centerY-bmpCenter.getHeight()/2, null); cvs.drawBitmap(bmpOuter, centerX-bmpOuter.getWidth()/2, centerY-bmpOuter.getHeight()/2, null); mtx.setRotate(rotateAngle, centerX, centerY); cvs.setMatrix(mtx); cvs.drawBitmap(bmp, centerX-bmp.getWidth()/2, centerY-bmp.getHeight()/2, null); } public boolean onTouchEvent(MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_DOWN) { downX = e.getX(); downY = e.getY(); //确保触摸点在旋转指针图片上 if (getDistance(downX, downY, centerX, centerY)>bmpCenter.getWidth()/2 && getDistance(downX, downY, centerX, centerY)<bmp.getWidth()/2) { isTouch = true; } else { isTouch = false; } } else if (e.getAction() == MotionEvent.ACTION_MOVE) { if (isTouch) { rotateAngle = calAngle(downX, downY, e.getX(), e.getY()); Log.e("MyView", "rotateAngle:" + rotateAngle); invalidate(); } } else if (e.getAction() == MotionEvent.ACTION_UP) { } return true; } public float calAngle(float x1, float y1, float x2, float y2) //计算旋转角度 { double dis1 = getDistance(x1, y1, centerX, centerY); double dis2 = getDistance(x2, y2, centerX, centerY); double dis = getDistance(x1, y1, x2, y2); //反余弦定理 double cos = (dis1+dis2-dis) / (2*(double)Math.sqrt(dis1)*(double)Math.sqrt(dis2)); return -(float)(Math.acos(cos) * 180 / Math.PI); } public float getDistance(float x1, float y1, float x2, float y2) //获取两点之间的距离 { return (float)Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); }} 本人新手,做练习用的。暂时还没想过要上苹App Store android 上传带进度条 java中, 有一个变量data,这个变量每五秒变更一次,如何求导? 在layout下面的xml中编辑控件的时候光标胡乱显示 求助!!!! Android手机震动 捕获摄像头的视频流 如何访问别的应用/data/data目录下的文件? 问个超简单问题!字符串的。。我是菜鸟~ android系统开发 初级问题, 找不到我添加手势库文件... 100分 刚刚接触安卓的新手,日志错误看不懂,求大神~~ android代码混淆后无法运行 android avd error in ubuntu(32) i nedd help
2.1 崩溃的程序将会被拒绝。
2.2 存在错误的程序将会被拒绝。
2.11 与App Store已有程序重复的应用可能会被拒绝,特别是数量很多的情况下,比如手电筒应用和爱经应用。
我已经做了一些,但旋转角度老有问题,现贴上代码,求指导
public class MyView extends View
{
private Bitmap bmp; //旋转指针图片
private Bitmap bmpCenter; //中心的开关按钮图片
private Bitmap bmpOuter; //旋转指针图片对应的旋转刻度图片
//开关按钮中心点坐标
private float centerX;
private float centerY;
//起始触摸点坐标
private float downX;
private float downY;
private Matrix mtx;
private float rotateAngle; //旋转角度
private boolean isTouch; //判断触摸点是否在旋转指针图片上
public MyView(Context ctt, float x, float y)
{
super(ctt);
bmp = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_rotating)).getBitmap();
bmpCenter = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_flashlight_switch_close)).getBitmap();
bmpOuter = ((BitmapDrawable)getResources().getDrawable(R.drawable.ic_scale_bg)).getBitmap();
centerX = x;
centerY = y;
downX = 0;
downY = 0;
isTouch = false; mtx = new Matrix();
}
@Override
public void onDraw(Canvas cvs)
{
super.onDraw(cvs);
cvs.drawBitmap(bmpCenter, centerX-bmpCenter.getWidth()/2, centerY-bmpCenter.getHeight()/2, null);
cvs.drawBitmap(bmpOuter, centerX-bmpOuter.getWidth()/2, centerY-bmpOuter.getHeight()/2, null);
mtx.setRotate(rotateAngle, centerX, centerY);
cvs.setMatrix(mtx);
cvs.drawBitmap(bmp, centerX-bmp.getWidth()/2, centerY-bmp.getHeight()/2, null); }
public boolean onTouchEvent(MotionEvent e)
{ if (e.getAction() == MotionEvent.ACTION_DOWN)
{
downX = e.getX();
downY = e.getY();
//确保触摸点在旋转指针图片上
if (getDistance(downX, downY, centerX, centerY)>bmpCenter.getWidth()/2
&& getDistance(downX, downY, centerX, centerY)<bmp.getWidth()/2)
{
isTouch = true;
}
else
{
isTouch = false;
}
}
else if (e.getAction() == MotionEvent.ACTION_MOVE)
{
if (isTouch)
{
rotateAngle = calAngle(downX, downY, e.getX(), e.getY());
Log.e("MyView", "rotateAngle:" + rotateAngle);
invalidate();
}
}
else if (e.getAction() == MotionEvent.ACTION_UP)
{
}
return true;
}
public float calAngle(float x1, float y1, float x2, float y2) //计算旋转角度
{
double dis1 = getDistance(x1, y1, centerX, centerY);
double dis2 = getDistance(x2, y2, centerX, centerY);
double dis = getDistance(x1, y1, x2, y2);
//反余弦定理
double cos = (dis1+dis2-dis) / (2*(double)Math.sqrt(dis1)*(double)Math.sqrt(dis2));
return -(float)(Math.acos(cos) * 180 / Math.PI);
}
public float getDistance(float x1, float y1, float x2, float y2) //获取两点之间的距离
{
return (float)Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}
}