java - How to detect screen orientation change? - JavaFX on Microsoft Surface -
i writing javafx application microsoft surface , looking way detect screen orientation change when rotating device portrait landscape , vice versa. current method using detect screen orientation follows:
window.widthproperty().addlistener((obs, oldval, newval) -> { if((double) newval < window.getheight()) { setportraitmode(); } else { setlandscapemode(); } });
this method works fine manual window resizing. however, orientation change (device rotation) not trigger window resize event, method change layout not fire automatically.
what proper way detect screen orientation change without listening resizing event?
the solution issue check change in aspect ratio. condition used:
if((double) newval < window.getheight() || ((double) newval/visualbounds.getheight() < 1.5)
Comments
Post a Comment