question

CarolousGhobrial-2782 avatar image
0 Votes"
CarolousGhobrial-2782 asked ColeXia-MSFT commented

Carouselview doesnt update when changing device orientatoin on IOS

The CarouselView doesn't relayout when changing the device orientation.

Steps to Reproduce
Run Project
Tilt your Device to landscape/portrait mode
Expected Behavior
The View should adjust to the new heights/widths, like on Android.

Actual Behavior
The View doesn't relayout. Some parts become invisible or look

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ColeXia-MSFT avatar image
0 Votes"
ColeXia-MSFT answered ColeXia-MSFT commented

Hello,

Welcome to Microsoft Q&A!

Normally there are two ways to solve the problem .

  • We use regular layout(e.g StackLayout, Grid) and detect the device rotation with OnSizeAllocated method in Forms , adjust the UI based on the orientation of the device.


protected override void OnSizeAllocated (double width, double height){
    base.OnSizeAllocated (width, height);
    if (width != this.width || height != this.height) {
        this.width = width;
        this.height = height;
        if (width > height) {
            //adjust ui 
        } else {
            //adjust ui 
        }
    }
}


  • Use RelativeLayout directly , in this way there is no need for procedural code to introduce responsiveness.


Refer to https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/device-orientation?tabs=windows.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

May I know whether your issue has been solved or not? If not, please share it in here. We can work together to figure it out.

0 Votes 0 ·