diff --git a/powermenu/build.gradle b/powermenu/build.gradle index de5e0f7..37e1f60 100644 --- a/powermenu/build.gradle +++ b/powermenu/build.gradle @@ -5,7 +5,7 @@ publish { userOrg = 'devmagician' groupId = 'com.github.skydoves' artifactId = 'powermenu' - publishVersion = '2.0.3' + publishVersion = '2.0.4' desc = 'This is PowerMenu by skydoves' website = 'https://github.com/skydoves/PowerMenu' issueTracker = "${website}/issues" diff --git a/powermenu/src/main/java/com/skydoves/powermenu/CustomPowerMenu.java b/powermenu/src/main/java/com/skydoves/powermenu/CustomPowerMenu.java index 4e04d1a..ad211c9 100644 --- a/powermenu/src/main/java/com/skydoves/powermenu/CustomPowerMenu.java +++ b/powermenu/src/main/java/com/skydoves/powermenu/CustomPowerMenu.java @@ -63,6 +63,7 @@ public class CustomPowerMenu> implements IMenuIt private boolean showBackground = true; private boolean allowTouchBackground = false; + private boolean fixedHeight = false; private boolean isShowing = false; @@ -250,7 +251,9 @@ private void showPopup(View anchor) { if(showBackground) backgroundWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0); isShowing = true; setWidth(getContentViewWidth()); - setHeight(getContentViewHeight()); + + if(fixedHeight) setHeight(menuWindow.getHeight()); + else setMeasuredHeight(getContentViewHeight()); } public void dismiss() { @@ -328,6 +331,11 @@ public void setWidth(int width) { } public void setHeight(int height) { + this.fixedHeight = true; + this.menuWindow.setHeight(height); + } + + private void setMeasuredHeight(int height) { this.menuWindow.setHeight(height); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) menuListView.getLayoutParams(); layoutParams.height = height - contentViewPadding; diff --git a/powermenu/src/main/java/com/skydoves/powermenu/PowerMenu.java b/powermenu/src/main/java/com/skydoves/powermenu/PowerMenu.java index 667e823..f4a3de4 100644 --- a/powermenu/src/main/java/com/skydoves/powermenu/PowerMenu.java +++ b/powermenu/src/main/java/com/skydoves/powermenu/PowerMenu.java @@ -62,6 +62,7 @@ public class PowerMenu implements IMenuItem, LifecycleObserver { private boolean showBackground = true; private boolean allowTouchBackground = false; + private boolean fixedHeight = false; private boolean isShowing = false; @@ -255,7 +256,9 @@ private void showPopup(View anchor) { if(showBackground) backgroundWindow.showAtLocation(anchor, Gravity.CENTER, 0, 0); isShowing = true; setWidth(getContentViewWidth()); - setHeight(getContentViewHeight()); + + if(fixedHeight) setHeight(menuWindow.getHeight()); + else setMeasuredHeight(getContentViewHeight()); } public void dismiss() { @@ -332,6 +335,11 @@ public void setWidth(int width) { } public void setHeight(int height) { + this.fixedHeight = true; + this.menuWindow.setHeight(height); + } + + private void setMeasuredHeight(int height) { this.menuWindow.setHeight(height); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) menuListView.getLayoutParams(); layoutParams.height = height - contentViewPadding;