|
|
@@ -103,10 +103,12 @@ public class CropView extends View {
|
|
|
sY = (getHeight()-coverHeight)/2;
|
|
|
break;
|
|
|
case SCAN_TYPE_ALL:
|
|
|
- coverWidth = getWidth();
|
|
|
+ isLandscape = true;
|
|
|
coverHeight = getHeight();
|
|
|
+ coverWidth = (int) (coverHeight/1.73);
|
|
|
+
|
|
|
// 起始位置
|
|
|
- sX = 0;
|
|
|
+ sX = (getWidth()-coverWidth)/2;
|
|
|
sY = 0;
|
|
|
break;
|
|
|
default:
|
|
|
@@ -116,6 +118,31 @@ public class CropView extends View {
|
|
|
init();
|
|
|
}
|
|
|
|
|
|
+ private boolean isLandscape = true;
|
|
|
+ /**
|
|
|
+ * 切换横竖屏
|
|
|
+ */
|
|
|
+ public void switchOrientation() {
|
|
|
+ if (isLandscape) {
|
|
|
+ coverWidth = getWidth();
|
|
|
+ coverHeight = (int) (coverWidth/1.73);
|
|
|
+ isLandscape = false;
|
|
|
+ sX = 0;
|
|
|
+ sY = (getHeight()-coverHeight)/2;
|
|
|
+ } else {
|
|
|
+ coverHeight = getHeight();
|
|
|
+ coverWidth = (int) (coverHeight/1.73);
|
|
|
+ isLandscape = true;
|
|
|
+ sX = (getWidth()-coverWidth)/2;
|
|
|
+ sY = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 起始位置
|
|
|
+
|
|
|
+ init();
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressWarnings("deprecation")
|
|
|
private void init() {
|
|
|
|