From 0f1a6ed68c893ab818a46a71723a352c2fc8dc0b Mon Sep 17 00:00:00 2001 From: ChengTao Date: Tue, 20 Mar 2018 00:48:53 +0800 Subject: [PATCH] fix: BUG - The specified child already has a parent. You must call removeView() on the child's parent first. --- .../java/com/dewarder/holdinglibrary/HoldingButtonLayout.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/holdingbutton/src/main/java/com/dewarder/holdinglibrary/HoldingButtonLayout.java b/holdingbutton/src/main/java/com/dewarder/holdinglibrary/HoldingButtonLayout.java index 62747da..cf700dd 100644 --- a/holdingbutton/src/main/java/com/dewarder/holdinglibrary/HoldingButtonLayout.java +++ b/holdingbutton/src/main/java/com/dewarder/holdinglibrary/HoldingButtonLayout.java @@ -266,6 +266,9 @@ public boolean onTouchEvent(MotionEvent event) { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); + if (mHoldingCircle.getParent() != null){ + ((ViewGroup)mHoldingCircle.getParent()).removeView(mHoldingCircle); + } getDecorView().addView(mHoldingCircle, mHoldingDrawable.getIntrinsicWidth(), mHoldingDrawable.getIntrinsicHeight()); }