尝试以编程方式从相机设置位图时,GestureImageView 变为空白



我正在使用:https://github.com/jasonpolites/gesture-imageview

  • 在加载应用程序时,它在 GestureImageView 中有一个占位符图像,可以适当地捏合/缩放。我有一个按钮,当单击触发相机意图时,保存文件,然后我希望将该图像设置为手势图像视图中使用的源位图。

    GestureImageView imageView = (GestureImageView) findViewById(R.id.imageViewOne);

    ContentResolver cr = getContentResolver();
    getContentResolver().notifyChange(imageUriOne, null);
    
                    try {
    Bitmap mybitmap =  android.provider.MediaStore.Images.Media.getBitmap(cr, imageUriOne);
     imageView.setImageBitmap(mybitmap);
    

    }

对于普通的图像视图,这是有效的。但是对于GestureImageView,一旦从相机意图返回,图像就会保持原始状态,如果触摸,图像就会消失。

要检查问题不是位图,我尝试了

int idTwo=getResources().getIdentifier("com.jazz.test1:drawable/second_photo", null, null);
imageView.setImageResource(idTwo);

即将图像视图设置为现有资源,但这具有相同的问题。

如果我在意图之前调用该 setImageResource 代码,它确实有效。

任何想法如何调试?日志中没有错误。

分辨率在这里:

https://github.com/jasonpolites/gesture-imageview/issues/21

  • 当我最初查看 github 问题时没有注意到它。

你必须替换你的 initMethod 函数。使用此代码,它将正常工作(GestureImageView.java com.polites.android包中的文件)。

protected void initImage() {
        if (this.drawable != null) {
            this.drawable.setAlpha(alpha);
            this.drawable.setFilterBitmap(true);
            if (colorFilter != null) {
                this.drawable.setColorFilter(colorFilter);
            }
            // Keppel.Cao
            layout = false;
            startingScale = -1.0f;
        }
        if (!layout) {
            requestLayout();
            // Keppel.Cao
            // redraw();
            reset();
        }
}

就像戴夫说的。更多你可以在这里找到 问题 21

相关内容

  • 没有找到相关文章

最新更新