1

我正在参与ImageView进度SeekBar更改事件。如果SeekBar增量更改,它似乎工作正常。在减少搜索栏进度的同时,保留已绘制的线。如果减少进度,如何从SeekBar进度更改事件事件中用适当的笔划画线。我尝试将ImageView's drawable 设置为null,并将图像位图设置为null,仍然面临错误。

@Override       
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {     
    imageCanvas.drawLine(0, 0, 100, 100, paint);                 
    mStrokeWidth = (float)progress;
    imageView.setImageDrawable(null);
    imageView.setImageBitmap(null);
    paint.setColor(mStrokeColor);
    paint.setStrokeWidth(mStrokeWidth);
    imageCanvas.drawLine(20, 20, 100, 100, paint);
    imageView.setImageBitmap(bitmap);
}
4

1 回答 1

0

该问题已针对创建新位图并将其分配给 onProgressChanged() 方法中的画布进行了修复。

@Override       
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) 
{
  bitmap = Bitmap.createBitmap((int)imageViewSize , (int) imageViewSize, Bitmap.Config.ARGB_8888);
  imageCanvas = new Canvas(bitmap);
  imageCanvas.drawLine(0, 0, 100, 100, paint);                 
  mStrokeWidth = (float)progress;
  imageView.setImageDrawable(null);
  imageView.setImageBitmap(null);
  paint.setColor(mStrokeColor);
  paint.setStrokeWidth(mStrokeWidth);
  imageCanvas.drawLine(20, 20, 100, 100, paint);
  imageView.setImageBitmap(bitmap);
}
于 2013-03-01T05:30:11.740 回答