如何让一个圆围绕轴心转一定的角度 让一个圆形图片围绕圆心(轴心)旋转一定的角度,要用到什么哪个函数?每点击一次上下键就旋转一定角度!谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 两种方法1.canvas.rotate(角度);2.使用Matrix进行矩阵变化. /** * 图片旋转指定角度 * @param resizedBitmap 位图 * @param image View * @param scaleAngle 旋转角度值 * @return */ private ImageView pointerRotation(Bitmap resizedBitmap,ImageView image,int scaleAngle) { //scaleAngle=360-45+scaleAngle; int ScaleTimes=1; int oldWidth = resizedBitmap.getWidth(); int oldHeight = resizedBitmap.getHeight() ; /* ScaleTimes=1,维持1:1的宽高比例*/ int newWidth = resizedBitmap.getWidth()*ScaleTimes ; int newHeight = resizedBitmap.getHeight()*ScaleTimes ; float scaleWidth = (float) newWidth / resizedBitmap.getWidth(); float scaleHeight = (float) newHeight / resizedBitmap.getHeight(); Matrix matrix = new Matrix(); /* 使用Matrix.postScale设定维度 */ matrix.postScale(scaleWidth, scaleHeight); /* 使用Matrix.postRotate方法旋转Bitmap*/ //matrix.postRotate(5*ScaleAngle); matrix.setRotate(scaleAngle); /* 建立新的Bitmap对象 */ resizedBitmap =Bitmap.createBitmap(resizedBitmap, 0, 0, oldWidth, oldHeight, matrix, true); /**/ BitmapDrawable myNewBitmapDrawable =new BitmapDrawable(resizedBitmap); image.setImageDrawable(myNewBitmapDrawable); //imageView1.image.setBackgroundResource(R.drawable.mainbuttoneffect); int h=resizedBitmap.getHeight(); int w=resizedBitmap.getWidth(); image.setLayoutParams ( new AbsoluteLayout.LayoutParams (w,h,(int) (screenW-w)/2,(int)(screenH-2*h)/2 )); SourceLocationX=(screenW-w)/2; SourceLocationY=(screenH-2*h)/2; return image; }zh这是我从程序中截取的函数,试着改成你想要的,应该可以满足你的 需要设计界面,请达人帮忙 android手机中sim卡状态获得的相关问题 camera不预览但又能获得每一帧数据 微聊TM!一款基于手机通讯录为核心的移动即时通讯软件 装了JDK-SDK-Eclipse后提示 数据库表中的记录删不掉也更新不了??? 请问大家android开发分为哪些类型呢? android中利用wifi进行socket通信 实例 android 两个library 引用出现问题 用java怎么开发服务器? android 通过LayoutInflater获得View,但是如何获得View里的控件 findviewbyid找不到控件
1.canvas.rotate(角度);
2.使用Matrix进行矩阵变化.
* 图片旋转指定角度
* @param resizedBitmap 位图
* @param image View
* @param scaleAngle 旋转角度值
* @return
*/
private ImageView pointerRotation(Bitmap resizedBitmap,ImageView image,int scaleAngle)
{
//scaleAngle=360-45+scaleAngle;
int ScaleTimes=1;
int oldWidth = resizedBitmap.getWidth();
int oldHeight = resizedBitmap.getHeight() ;
/* ScaleTimes=1,维持1:1的宽高比例*/
int newWidth = resizedBitmap.getWidth()*ScaleTimes ;
int newHeight = resizedBitmap.getHeight()*ScaleTimes ;
float scaleWidth = (float) newWidth / resizedBitmap.getWidth();
float scaleHeight = (float) newHeight / resizedBitmap.getHeight();
Matrix matrix = new Matrix();
/* 使用Matrix.postScale设定维度 */
matrix.postScale(scaleWidth, scaleHeight);
/* 使用Matrix.postRotate方法旋转Bitmap*/
//matrix.postRotate(5*ScaleAngle);
matrix.setRotate(scaleAngle);
/* 建立新的Bitmap对象 */
resizedBitmap =Bitmap.createBitmap(resizedBitmap, 0, 0, oldWidth, oldHeight, matrix, true);
/**/
BitmapDrawable myNewBitmapDrawable =new BitmapDrawable(resizedBitmap);
image.setImageDrawable(myNewBitmapDrawable);
//imageView1.image.setBackgroundResource(R.drawable.mainbuttoneffect);
int h=resizedBitmap.getHeight();
int w=resizedBitmap.getWidth();
image.setLayoutParams ( new AbsoluteLayout.LayoutParams (w,h,(int) (screenW-w)/2,(int)(screenH-2*h)/2 ));
SourceLocationX=(screenW-w)/2;
SourceLocationY=(screenH-2*h)/2;
return image;
}zh
这是我从程序中截取的函数,试着改成你想要的,应该可以满足你的