You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a problem with screen rotate under Python for Android.
The example below does not re-layout on device rotation. The contents does rotate, but is not not resized for the new width and height. It does re-layout when I tap the screen after rotation.
It is compiled with "--orientation sensor". I am using p4a master branch dated 5/17/2018.
On device rotation, I'm looking for a way to trigger re-layout from Python. My code can implement the re-layout.
It appears that on_pause() and on_resume() are called when the app enters/returns from the background. Unlike Java on Android they are not called on rotation. Not my expectation, but I can see why it is that way.
It appears that on_rotate() is never called, either from the App class or layout class. What am I missing?
Once I have a trigger I assume I will have to get the new size using Java, because Python's Window.size does not appear to be updated till after re-layout.
Suggestions for handling screen rotation re-layout?
First, the workaround I used is below. This depends on a heartbeat, there has to be a better way?!
Second, I notice Settings().add_kivy_panel() has a 'rotation' key. On Windows and Android this rotates the window on all subsequent window create(). The App class also has a on_config_change() callback which should respond to changes in this key, this callback is a new addition and not released.
From an Android/Java viewpoint rotation is (re) creation. I suggest if , on device rotation, the Kivy Android bootstrap were to set the value of the 'rotation' key (and the callback were released). There would be an effective on_rotate() callback. An enhancement request for your consideration.
class LifecycleApp(App):
def __init__(self,**kwargs):
super (LifecycleApp,self).__init__(**kwargs)
self.screen = None
self.x, self.y = Window.size
def build(self):
self.screen = LifecycleScreen()
Clock.schedule_interval(self.potential_on_rotate,1)
return self.screen
def potential_on_rotate(self,dt):
x,y = Window.size
if self.x == y and self.y == x:
self.x = x
self.y = y
self.on_rotate()
def on_rotate(self):
self.screen.canvas.ask_update()
I am having a problem with screen rotate under Python for Android.
The example below does not re-layout on device rotation. The contents does rotate, but is not not resized for the new width and height. It does re-layout when I tap the screen after rotation.
It is compiled with "--orientation sensor". I am using p4a master branch dated 5/17/2018.
On device rotation, I'm looking for a way to trigger re-layout from Python. My code can implement the re-layout.
It appears that on_pause() and on_resume() are called when the app enters/returns from the background. Unlike Java on Android they are not called on rotation. Not my expectation, but I can see why it is that way.
It appears that on_rotate() is never called, either from the App class or layout class. What am I missing?
Once I have a trigger I assume I will have to get the new size using Java, because Python's Window.size does not appear to be updated till after re-layout.
Suggestions for handling screen rotation re-layout?
Thanks.
The text was updated successfully, but these errors were encountered: