我想根据android中的特定角度旋转图像,有些像指南针...
我有这个代码...它适用于drawPath(),但我想用图像替换路径和绘图的东西..我试图创建一个位图图像,DrawBitmapImage,但图像不像路径一样旋转..任何请帮忙?
public void draw(Canvas canvas) {
double angle = calculateAngle(currentLongitude, currentLatitude, targetLongitude, targetLatitude);
//Correction;
angle-=90;
//Correction for azimuth
angle-=azimuth;
if((getContext() instanceof Activity) && ((Activity)getContext()).getWindowManager().getDefaultDisplay().getOrientation()==Configuration.ORIENTATION_PORTRAIT)angle-=90;
while(angle<0)angle=angle+360;
Rect rect = canvas.getClipBounds();
int height = rect.bottom-rect.top;
int width = rect.right-rect.left;
int left = rect.left;
int top = rect.top;
if(height>width){
top+=(height-width)/2;
height=width;
}
if(width>height){
left+=(width-height)/2;
width=height;
}
float centerwidth = width/2f;
float centerheight = height/2f;
Paint p = new Paint();
p.setColor(color);
p.setStyle(Paint.Style.FILL);
p.setAntiAlias(true);
float startX = left+(float)(centerwidth+Math.cos(deg2rad(angle))*width/3.0);
float startY = top+(float)(centerheight+Math.sin(deg2rad(angle))*height/3.0);
Path path …Run Code Online (Sandbox Code Playgroud) <rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/your_drawable"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
Run Code Online (Sandbox Code Playgroud)
我想以编程方式旋转drawable.
我该怎么办?
这是我的回调
private class RotateListener implements RotateGestureDetector.OnRotateGestureListener{
@Override
public boolean onRotate(MotionEvent event1, MotionEvent event2,
double deltaAngle) {
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
在deltaangle不大于0.1,我不知道什么是提取价值.
我MapView在Android应用程序中使用该Google Maps组件.我可以使用GPS位置用点显示我的位置.但是我想显示一个箭头,指出行驶方向(方位).我认为我可以使用该bearing值来获得箭头的角度.
我怎样才能做到这一点?
我有一个与android中的GUI设计有关的问题.
如果您看一下Android设计架构,我们在设计视图中有表格结构.我们可以按行和列绘制按钮,我们可以绘制图像视图等等,但我们将在矩阵中进行所有操作.... 如下图所示.

但我在Android中看到了许多有趣的GUI设计,它看起来非常漂亮,看起来不像传统的设计视图(矩阵形式).
用锯齿形按钮检查下图.我画了红色方块.

我不确定它是如何设计的以及如何捕获不同图像和按钮的onclick功能.我希望我能很好地解释我的问题,请告诉我是否不清楚.我寻求健康的反应和帮助.
我想知道如果在图像视图中设置或设置为相对布局的背景,我是否可以使图像不透明.
如何使用图像视图或相对布局使图像不透明以动态设置图像,或者是否有其他选项可动态设置图像及其不透明度?
我也希望相同的图像在两个方向上旋转,也可以缩放和缩放到任何级别.
提前致谢