B4J Question [ABMaterial]: Changing the Page Orientation?

Mashiane

Expert
Licensed User
Longtime User
Hi there

Some wishful thinking. Is it something possible for when one navigates to a particular page in ABM, the page orientation is rendered in LandScape mode and locked there so that the user is forced to tilt the device, esp small devices?

Of course the other pages that might not have that set display in usual fashion.

Thanks.
 

alwaysbusy

Expert
Licensed User
Longtime User
Although this must be extremely annoying to the user (it means you haven't build your app taking all screensizes/orientations into account with the grid), maybe you can use something like this:

B4X:
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation:portrait) {
  body {
   -webkit-transform: rotate(90deg);
   width: 100%;
   height: 100%;
   overflow: hidden;
   position: absolute;
   top: 0;
   left: 0;
  }
}

B4X:
$(document).ready(function () {
  function reorient(e) {
   var portrait = (window.orientation % 180 == 0);
   $("body").css("-webkit-transform", !portrait ? "rotate(-90deg)" : "");
  }
  window.onorientationchange = reorient;
  window.setTimeout(reorient, 0);
});
 
Upvote 0
Top