From 399e6d957b207112a75d9ec786e6f5c9126d7bb6 Mon Sep 17 00:00:00 2001 From: samlss <729717222@qq.com> Date: Thu, 3 Jan 2019 17:32:56 +0800 Subject: [PATCH] fix bug --- .../main/java/me/samlss/lighter/view/LighterView.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lighter/src/main/java/me/samlss/lighter/view/LighterView.java b/lighter/src/main/java/me/samlss/lighter/view/LighterView.java index 7f48b27..4522d38 100644 --- a/lighter/src/main/java/me/samlss/lighter/view/LighterView.java +++ b/lighter/src/main/java/me/samlss/lighter/view/LighterView.java @@ -168,6 +168,7 @@ private LayoutParams calculateLayoutParams(int width, int height, LighterParamet return layoutParams; } + boolean alignRight = false; switch (lighterParameter.getTipViewRelativeDirection()){ default: case Direction.LEFT: @@ -182,6 +183,7 @@ private LayoutParams calculateLayoutParams(int width, int height, LighterParamet case Direction.TOP: if (highlightedViewRect.left > width / 2){ //on the right + alignRight = true; layoutParams.rightMargin = (int) (width - highlightedViewRect.right + marginOffset.getRightOffset()); }else{ //on the left layoutParams.leftMargin = (int) (highlightedViewRect.left + marginOffset.getLeftOffset()); @@ -191,6 +193,7 @@ private LayoutParams calculateLayoutParams(int width, int height, LighterParamet case Direction.BOTTOM: if (highlightedViewRect.left > width / 2){ //on the right + alignRight = true; layoutParams.rightMargin = (int) (width - highlightedViewRect.right + marginOffset.getRightOffset()); }else{ //on the left layoutParams.leftMargin = (int) (highlightedViewRect.left + marginOffset.getLeftOffset()); @@ -199,7 +202,8 @@ private LayoutParams calculateLayoutParams(int width, int height, LighterParamet break; } - if(layoutParams.rightMargin != 0){ + if(layoutParams.rightMargin != 0 + || alignRight){ layoutParams.gravity = Gravity.RIGHT; }else { layoutParams.gravity = Gravity.LEFT; @@ -231,8 +235,7 @@ protected void onDraw(Canvas canvas) { mBgColor = ViewUtils.DEFAULT_HIGHLIGHT_VIEW_BG_COLOR; } - canvas.save(); - +// canvas.save(); //firstly, clip the rects of all the highlighted views. if (mLighterParameterList != null && !mLighterParameterList.isEmpty()) { for (LighterParameter lighterParameter : mLighterParameterList) { @@ -262,7 +265,7 @@ protected void onDraw(Canvas canvas) { } } - canvas.restore(); +// canvas.restore(); } public void setInitHeight(int initHeight) {