33import android .content .Context ;
44import android .graphics .Canvas ;
55import android .graphics .Rect ;
6+ import android .os .Build ;
67import android .support .annotation .NonNull ;
78import android .util .AttributeSet ;
89import android .view .MotionEvent ;
@@ -20,6 +21,8 @@ public class CropImageView extends ImageViewTouchBase {
2021 private int motionEdge ;
2122 private int validPointerId ;
2223
24+ private int softNavbarHeight = 0 ;
25+
2326 public CropImageView (Context context ) {
2427 super (context );
2528 }
@@ -35,6 +38,14 @@ public CropImageView(Context context, AttributeSet attrs, int defStyle) {
3538 @ Override
3639 protected void onLayout (boolean changed , int left , int top , int right , int bottom ) {
3740 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+
3849 if (bitmapDisplayed .getBitmap () != null ) {
3950 for (HighlightView hv : highlightViews ) {
4051
@@ -143,7 +154,7 @@ private void ensureVisible(HighlightView hv) {
143154 int panDeltaX2 = Math .min (0 , getRight () - r .right );
144155
145156 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 );
147158
148159 int panDeltaX = panDeltaX1 != 0 ? panDeltaX1 : panDeltaX2 ;
149160 int panDeltaY = panDeltaY1 != 0 ? panDeltaY1 : panDeltaY2 ;
0 commit comments