Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Strange padding in ListView on iPhone X

VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭
edited March 2018 in Xamarin.iOS

Hi everyone.
I was improving my app's interface for iPhone X and faced a problem with ListView.
As can you see on screenshot below ListView adds strange padding to ViewCells on iPhone X. On other iPhones without notch everything is okay.
How can i remove it?
I use custom ListView, so i can get access to all properties of UIListView.!

Answers

  • Ajay87Ajay87 INMember ✭✭✭

    @VolodymyrSavchenko
    xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
    ios:Page.UseSafeArea="true"
    Add this namespace into your xaml page where you want.

  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭

    @Ajay87 said:
    @VolodymyrSavchenko
    xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
    ios:Page.UseSafeArea="true"
    Add this namespace into your xaml page where you want.

    Thanks for replying, but this won't help. With this option turned on listview looks okay only if you'll open app in landscape orientation.
    I binded to this property on my ViewModel and changing it's value when app changes orientation.
    If I rotate app to portrait mode and then back to landscape this option's value don't change and app look ugly again.

    I just don't understand why microsoft and xamarin team hates us? Why they did this? I want to improve my app's UI for iPhone X by myself. I don't want any of those stupid auto "improvements" which don't help, but make UI optimization only harder.

  • Ajay87Ajay87 INMember ✭✭✭

    @VolodymyrSavchenko

    protected override void OnSizeAllocated(double width, double height)
    {
    base.OnSizeAllocated(width, height); // Important!
    if (width != _width || height != _height)
    {
    _width = width;
    _height = height;
    ShowExtraLayout(width > height);
    }
    }
    you can do anything inside ShowExtraLayout() this method
    may be it will help you.

  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭

    @Ajay87 said:
    @VolodymyrSavchenko

    protected override void OnSizeAllocated(double width, double height)
    {
    base.OnSizeAllocated(width, height); // Important!
    if (width != _width || height != _height)
    {
    _width = width;
    _height = height;
    ShowExtraLayout(width > height);
    }
    }
    you can do anything inside ShowExtraLayout() this method
    may be it will help you.

    I use exactly the same code and override same method. When i turn device to portrait mode safe area turns off, but when i return it to landscape mode nothing happens. Safe area don't appear.

  • Ajay87Ajay87 INMember ✭✭✭

    @VolodymyrSavchenko
    You need to give if And else both condition in this method on the basis of orientation

  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭

    @Ajay87 said:
    @VolodymyrSavchenko
    You need to give if And else both condition in this method on the basis of orientation

    As i said i bind UseSafeArea to property. Property changes. This part works. Don't work listview. It handles property changing from landscape to portrait. But don't work other way.

  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭
    edited March 2018

    I made few screenshots with what i got with "UseSafeArea" option and what i made by myself;
    Feel the difference.

    Xamarin:


    Mine:

  • BethBaraleckiBethBaralecki Member
    edited April 2018

    @VolodymyrSavchenko I am experiencing the same strange issue. Were you ever able to resolve this?

    Edit: I realized that on my view, I was calling InitializeComponent from the OnAppearing override. Taking this line out fixed my issue. I do not know why though.

  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭

    @BethBaralecki said:
    @VolodymyrSavchenko I am experiencing the same strange issue. Were you ever able to resolve this?

    Edit: I realized that on my view, I was calling InitializeComponent from the OnAppearing override. Taking this line out fixed my issue. I do not know why though.

    Hello.
    I used minus margin like Margin = "-60, 0, 0, 0".

  • Pedro_PazPedro_Paz Member ✭✭

    @Ajay87 said:
    @VolodymyrSavchenko
    xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
    ios:Page.UseSafeArea="true"
    Add this namespace into your xaml page where you want.

    Thank you man <3

Sign In or Register to comment.