3
3
import android .content .Context ;
4
4
import android .graphics .Canvas ;
5
5
import android .graphics .Rect ;
6
+ import android .os .Build ;
6
7
import android .support .annotation .NonNull ;
7
8
import android .util .AttributeSet ;
8
9
import android .view .MotionEvent ;
@@ -20,6 +21,8 @@ public class CropImageView extends ImageViewTouchBase {
20
21
private int motionEdge ;
21
22
private int validPointerId ;
22
23
24
+ private int softNavbarHeight = 0 ;
25
+
23
26
public CropImageView (Context context ) {
24
27
super (context );
25
28
}
@@ -35,6 +38,14 @@ public CropImageView(Context context, AttributeSet attrs, int defStyle) {
35
38
@ Override
36
39
protected void onLayout (boolean changed , int left , int top , int right , int bottom ) {
37
40
super .onLayout (changed , left , top , right , bottom );
41
+
42
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ) {
43
+ int resID = getResources ().getIdentifier ("navigation_bar_height" , "dimen" , "android" );
44
+ if (resID > 0 ){
45
+ softNavbarHeight = getResources ().getDimensionPixelSize (resID );
46
+ }
47
+ }
48
+
38
49
if (bitmapDisplayed .getBitmap () != null ) {
39
50
for (HighlightView hv : highlightViews ) {
40
51
@@ -143,7 +154,7 @@ private void ensureVisible(HighlightView hv) {
143
154
int panDeltaX2 = Math .min (0 , getRight () - r .right );
144
155
145
156
int panDeltaY1 = Math .max (0 , getTop () - r .top );
146
- int panDeltaY2 = Math .min (0 , getBottom () - r .bottom );
157
+ int panDeltaY2 = Math .min (0 , getBottom () - r .bottom - softNavbarHeight );
147
158
148
159
int panDeltaX = panDeltaX1 != 0 ? panDeltaX1 : panDeltaX2 ;
149
160
int panDeltaY = panDeltaY1 != 0 ? panDeltaY1 : panDeltaY2 ;
0 commit comments