Android Question B4X changing Orientation and resizing pages problem

amer bashar

Member
Licensed User
Hi,
for implementing change how my app looks if screen orientation changed , I followed this steps :
1- add this line to manifest to stop activity from create:
B4X:
SetActivityAttribute(Main, android:configChanges, "orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation")
2- in main :
B4X:
    #SupportedOrientations: unspecified
3- using GetDeviceLayoutValues for detecting orientation changes:
B4X:
Sub timerorient_tick()
 
        If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
            CheckScrOrientation = "Landscape"
        Else
            CheckScrOrientation = "Portrait"
        End If
        If CheckScrOrientation <> StoredOrientation Then
            StoredOrientation = CheckScrOrientation

            Root.RemoveAllViews
            Root.Width=GetDeviceLayoutValues.Width
            Root.Height=GetDeviceLayoutValues.Height
            Root.LoadLayout("my_layout")

        End If
 
End Sub
The problem is that the app don`t show all the root width or height, I mean the ROOT width and height changes correctly but the app not showing all the page some area is missing ! it using the old dimensions for showing the corrected dimensions root , I can`t explain it well the screenshot explained it
Please notice the second screenshot that the components are displayed on their correct locations this means that the root width is correct!
your help is so appreciated
 

Attachments

  • Screenshot_20211017-154243[1].jpg
    Screenshot_20211017-154243[1].jpg
    418 KB · Views: 102
  • Screenshot_20211017-154257 copy.jpg
    Screenshot_20211017-154257 copy.jpg
    364 KB · Views: 100

amer bashar

Member
Licensed User
Why? Just have portrait and landscape variants in your layout file.
These variant tells what is the current situation (portrait or landscape ) ok very good, but the problem is about something else , its about how to resize the root or the layout to the correct dimensions .
also all my views have the AutoScaleAll but with the same result , also if I tried to resize components in the designer script every thing to 100%x width and height , always with the same result mentioned in my screenshots above
please Help !!
 
Upvote 0
Top