Android MediaStore裁剪功能,如何使选择箭头始终可见? [英] Android MediaStore Crop function, how to make selection arrows always visible?

查看:267
本文介绍了Android MediaStore裁剪功能,如何使选择箭头始终可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作图片选择/裁剪程序并使用以下代码:

I'm working on a picture select/crop program and using this code below:

http://www.androidworks.com/crop_large_photos_with_android/comment-page-1#comment-969

据我所知,我们设置了属性,为我们的意图添加额外内容,如下面的代码。

As far as I could understand we set properties with putting extras to our intent like the code below.

为了改变选择范围我们需要触摸边框然后箭头变得可见但我想要做的是让它们始终可见,因为很难让用户理解这种方式。 Instagram的Android应用就是这样做的,所以我想有办法做到这一点。

In order to change selection area we need to touch the border and then arrows became visible but what I want to do is make them always visible because it is hard to make user understand that way. Instagram's Android application do it that way so I guess there is a way to do that.

谢谢。

Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
                intent.setType("image/*");
                intent.putExtra("crop", "true");
                intent.putExtra("aspectX", aspectX);
                intent.putExtra("aspectY", aspectY);
                intent.putExtra("outputX", outputX);
                intent.putExtra("outputY", outputY);
                intent.putExtra("scale", scale);
                intent.putExtra("return-data", return_data);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());

编辑/解决方案:
感谢@Renard我发现像这样的解决方案:

Edit / solution: Thanks to @Renard I found solution like this:

我使用了这个图库源代码:
http://gitorious.org/0xdroid/packages_apps_gallery3d/trees/3c02f2877dc2f8f0b5c01d03fa2b487c040e4000

I used this gallery source code: http://gitorious.org/0xdroid/packages_apps_gallery3d/trees/3c02f2877dc2f8f0b5c01d03fa2b487c040e4000

我尝试了其他一些图库资源代码,但是这个是最容易维护的。

I tried some other gallery resource code too but this one is the easiest one to maintain.

如果签入Highlightview.java类'draw()函数,你只需要删除下面的内容:

You just need to delete below if check in Highlightview.java class' draw() function:

if (mMode == ModifyMode.Grow)  

当你这样做时它会起作用,但箭头在移动时会自我重复,以避免你需要改变moveBy()方法的最后一行,即:

When you do that it works but the arrows are repating itself while moving and in order to avoid that you need to change moveBy() method's last line which is:

mContext.invalidate(invalRect);

这个:

mContext.invalidate();


推荐答案

是的,有办法。但这并不容易。

Yes there is a way. But it is not easy.

检查Gallery应用程序的源代码。特别是HighlightView.java。您将看到负责绘制箭头的方法仅在用户触摸边框时调用。
所以你需要获取CropImage活动的源代码。将它包含在你的应用程序中并修改HighlightView.java的draw()方法以始终调用drawResizeDrawables()。

Check the source code of the Gallery app. In particular HighlightView.java. You will see that the method which is responsible for drawing the arrows is only called when the user touches the borders. So you need to grab the source code of the CropImage activity. include it in your App and modify the draw() method of HighlightView.java to always call drawResizeDrawables().

这样做的好处是你可以确定crop intend可以在所有设备上运行,即使它们有一个不支持裁剪Intent的自定义Gallery。

The benefit of this is that you can be sure that the crop intend will work across all devices, even if they have a custom Gallery which does not support the crop Intent.

这篇关于Android MediaStore裁剪功能,如何使选择箭头始终可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆