我已经加载了平面图图像并将其转换为位图。我在该平面图上画了一个圆圈。此圆圈显示此用户在平面图上的当前位置。
问题是,当来自服务器的响应缓慢时,在平面图上绘制了多个圆圈
这是我的代码:
public void onServiceUpdate(ServiceState state) {
final int i, j;
i = state.getImagePoint().getI();
j = state.getImagePoint().getJ();
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.buildDrawingCache();
Bitmap bitmap = imageView.getDrawingCache();
final ImageView imageFloor = (ImageView) findViewById(R.id.imageView);
final Bitmap bitmapCircle = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
Canvas canvas = new Canvas(bitmapCircle);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);
paint.setStrokeWidth(10);
canvas.drawBitmap(bitmap, new Matrix(), null);
canvas.drawCircle(i, j, 10, paint);
runOnUiThread(new Runnable() {
@Override
public void run() {
imageFloor.setImageBitmap(bitmapCircle);
}
});
这是从indooratlas服务器调用楼层平面图的方法。
public void loadFloorPlanImage(FloorPlan floorPlan) {
BitmapFactory.Options options = createBitmapOptions(floorPlan);
FutureResult<Bitmap> result = mIndoorAtlas.fetchFloorPlanImage(floorPlan,options);
result.setCallback(new ResultCallback<Bitmap>() {
@Override
public void onResult(final Bitmap result) {
runOnUiThread(new Runnable() {
@Override
public void run() {
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(result);
log("onResult LoadFloorPlanImage");
}
});
}
是否有任何想法或建议如何清除平面图位图中的圆圈?
答案 0 :(得分:0)
你可以这样做:
onServiceUpdate(...){
final ImageView imageFloor = (ImageView) findViewById(R.id.imageView);
imageFloor.setVisibility(View.GONE);
....
runOnUiThread(new Runnable() {
@Override
public void run() {
imageFloor.setVisibility(View.VISIBLE);
imageFloor.setImageBitmap(bitmapCircle);
但你的问题不是很清楚,如果我不明白你的意思,我不会感到惊讶