我的想法是将两个图像重叠在一起,并且在onTouch上,顶部图像应该在触摸的半径上变得透明,从而暴露底部图像.
这是我叠加2张图片的方式:
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, new Matrix(), null);
Run Code Online (Sandbox Code Playgroud)
我已经查看了这篇文章,并在下面使用Paint来使其透明:
mPaint = new Paint();
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
mPaint.setColor(Color.TRANSPARENT);
mPaint.setAntiAlias(true);
public void onDraw(Canvas canvas) {
canvas.drawCircle(40, 40, 30, mPaint); //hardcode to test
}
Run Code Online (Sandbox Code Playgroud)
问题是,我认为圆圈直接使2个图像在定义的半径上透明,我怎样才能使顶部位图透明?
我想在画布上绘制带刻度线的圆圈.
圆圈包含100个刻度.但是在1到2之间存在比其他更多的子刻度,我还想根据用户输入(圆周旋转)计算刻度.请帮我..

我试过这个http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/
private void drawScale(Canvas canvas) {
//canvas.drawOval(scaleRect, scalePaint);
canvas.drawCircle(0.5f,0.5f, 0.49f,scalePaint);
canvas.save(Canvas.MATRIX_SAVE_FLAG);
for (i = 0; i < totalNicks; ++i) {
float y1 = scaleRect.top;
float y2 = y1 - 0.020f;
//canvas.drawLine(0.5f, y1, 0.5f, y2, scalePaint);
if (i % 1 == 0) {
int value = nickToDegree(i);
if(value<=360)
{
float y3 = 0;
scaleText =new Paint();
scaleText.setTextSize(0.035f);
scaleText.setColor(Color.BLACK);
scaleText.setTypeface(Typeface.DEFAULT_BOLD);
scaleText.setTextScaleX(0.8f);
scaleText.setTextAlign(Paint.Align.CENTER);
scaleText.setStrokeWidth(0.015f);
scaleText.setAntiAlias(true);
scaleline =new Paint();
scaleline.setStyle(Paint.Style.FILL);
scaleline.setColor(Color.BLACK);
scaleline.setStrokeWidth(0.005f);
scaleline.setAntiAlias(true);
switch …Run Code Online (Sandbox Code Playgroud) 创建一个简单的应用程序,计算您的速度并将其显示在速度表图形中.我可以做所有的速度计算,gps计算等.但我对动画不太确定.除了温度计示例之外,有没有人在针规上有任何好的教程或示例?
我已经写了一个应用程序,我有一个speedometer带有a needle,我试图center用速度变化旋转针.
我从互联网上计算下载速度的速度值,该角度也是测量的,
我的问题是如何将针头一端固定在车速表的中心?
如何通过改变角度值来旋转针?
我期待这样

这里针不固定中心位置如何像第一个图像中心一样固定图像的针中心