|
|
@@ -90,7 +90,6 @@ public class CropView extends View {
|
|
|
|
|
|
public CropView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
-
|
|
|
// 获取到宽高之后再初始化
|
|
|
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
@Override
|
|
|
@@ -100,6 +99,7 @@ public class CropView extends View {
|
|
|
BitmapFactory.Options horizontalOptions = new BitmapFactory.Options();
|
|
|
BitmapFactory.decodeResource(getResources(), R.mipmap.move_horizontal, horizontalOptions);
|
|
|
horizontalOptions.inJustDecodeBounds = true;
|
|
|
+ // 图片放在不同的文件夹下,outHeight会不一样,放在dpi越高的文件夹,值越小
|
|
|
minWidth = horizontalOptions.outHeight * 2;
|
|
|
minHeight = minWidth;
|
|
|
setScanArea(SCAN_TYPE_ALL); //height is ready
|
|
|
@@ -117,7 +117,8 @@ public class CropView extends View {
|
|
|
case SCAN_TYPE_POSTAL:
|
|
|
// 邮箱
|
|
|
coverWidth = (int) (getWidth()*0.815);
|
|
|
- coverHeight = (int) (getWidth()*0.3);
|
|
|
+ // 最小高度不能小于图片的高度
|
|
|
+ coverHeight = Math.max(minHeight, (int)(getWidth()*0.3));
|
|
|
sX = (getWidth()-coverWidth)/2;
|
|
|
sY = (int) (getWidth()*0.177);
|
|
|
break;
|