Prevent screen from rotating

Could you please help me finding the correct values to enter / set?

What has to be filled in there in order to set screen orientation?
I have to set android:screenOrientation="portrait" in action ?
What about the other properties?

before going further, the first thing you should do is to create a small test project to test this

to find out, if it works for you for a small project

Taifun

Ok, I did. What shall I say - It did what I expected. Locks the screen as wanted.

However, with my app, the behaviour is the same in principle, but what happens in terms of a time series:

  1. Screen is in landscape
  2. App runs procedure to scale components and draw on a canvas
  3. App rotates the screen to portrait
    -> scaling is wrong, canvas drawing is wrong

So I would like to try if using the intent solves my issue.
Please tell me which values have to be set for ActivityStarter properties.
Thank you

I'm not sure if I understand, what you are saying...

You set the Screen Orientation to Landscape, so the screen always is in landscape and can't be rotated to portrait...

Taifun

1 Like

I've set the TimerInterval = 2000 to better illustrate (the device orientation is landscape while the app starts and it doesn't matter if AutoRotation is enabled or not in the Settings):

Thank you very much for your efforts @Anke !

I think this example illustrates very well what is causing my issue. The screen width and height values are determined immediately at screen initialization. When screen is rotated, height and width are reversed.

If I understand correctly, it's all a matter of timing, right?

-> I need to delay the ScaleComponents procedure?

Or have I misinterpreted all of this?

1 Like

this is a misunderstanding, I meant to say when the device is held in landscape mode

1 Like

Yes, but since you already know beforehand that your app will be oriented in Portrait mode at the end, you can set this value (ScreenWidth=376 in my case) beforehand for the Canvas (or wherever it is needed).

did you find any solution for this ?cause even im facing the same issue

the correct answer is here

let us know, if this works for you
Taifun

tried that , it switches to landscape and then portrait , when the screen switches this happens
even when my devices auto rotate is off and also i have set the attribute orientation to portrait

Immagine1

1 Like

This Worked for me.
ai

1 Like