BoomMenu
BoomMenu copied to clipboard
Layout problem after screen rotation (configuration changed)
When app start in portait (all ok):
After activity rotation (with android:configChanges="keyboardHidden|orientation|screenSize"
and onConfigurationChanged overrided):
I can't recreate the entire activity. How can I manage this problem? Any way to "re-layout" the view?
Since version 2.1.1, you can set the orientation-adaptable property for BMB to deal with this problem. For more details, check orientation-example-activity.
After setting orientationAdaptable
to true I always receive this every time the orientation changes:
FATAL EXCEPTION: main
Process: com.-----.----, PID: 9015
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams com.nightonke.boommenu.BackgroundView.getLayoutParams()' on a null object reference
at com.nightonke.boommenu.BoomMenuButton.calculateEndPositions(BoomMenuButton.java:907)
at com.nightonke.boommenu.BoomMenuButton.access$2100(BoomMenuButton.java:66)
at com.nightonke.boommenu.BoomMenuButton$9.run(BoomMenuButton.java:1108)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
I got the same problem and same error with your orientation-adaptable solution. Do you have any other solution for this @Nightonke ?
Hello again, I solve the problem but it is not a cool solution. Before use bmb.setOrientationAdaptable(true) , BoomMenu simply needs to bmb.boomImmediately(). So it never crush but I do not want to boom each time when orientation changes. We need a cooler solution @Nightonke
I have a similar problem. For me it doesn't crash, and boomImmediately() works fine. But when using just boom() the buttons are still misaligned (the background however is correct). When rebooming they jump to the correct place in the center and then reboom from there. So there must be something wrong still with the boom animation.
See the gif: First I call the menu before any rotation, then I rotate the screen 90 degrees and call the menu again.
(I call the menu from a background service. It is in its own FrameLayout.)
I called boomImmediately() before bmb.setOrientationAdaptable(true) , but still I got the same problem.
The background variable was null when the function calculateEndPositions() has been called
please any solution? @Nightonke
bmb.setOnBoomListener( new OnBoomListenerAdapter() { @Override public void onBoomWillShow() { super.onBoomWillShow(); bmb.setOrientationAdaptable(true); } @Override public void onBoomDidHide() { super.onBoomDidHide(); bmb.setOrientationAdaptable(false); } });
+1
bmb.setOnBoomListener(
new OnBoomListenerAdapter() {
@Override
public void onBoomWillShow() {
super.onBoomWillShow();
bmb.setOrientationAdaptable(true);
}
@Override
public void onBoomDidHide() {
super.onBoomDidHide();
bmb.setOrientationAdaptable(false);
}
});
@AidanTheonas code worked for me but make sure that you only use setOrientationAdaptable
inside these listeners only.
i don't understand the reasoning behind it, but would still love to see a neat fix for this issue. @Nightonke