Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Listview on iOS 9 not filling screen width - issue with custom ViewCell

$
0
0

In iOS8 a simple Listview would have separator lines that filled the width (especially in landscape mode)
In iOS9 the Listview separator lines no longer fill the full width on a landscape iPad mini.

(first attached image is a simple list view with the ItemsSource set to an array of 3 strings)

This causes me a problem as I have custom ViewCells and they are left aligned on the screen and so appear out of alignment with the separator lines.

(see second attached image. I've used the code fragment below to have a custom ViewCell)

Here is a very short sample program.
Note in the custom ViewCell I don't bother to get the proper list contents. For now I just hard code a label which is enough for now.

Any ideas on how to fix this layout so it looks like iOS8 did with seperators filling the screen.

Thanks

UPDATE... Tried XamStudio Alpha (with Xam.iOS 8.13.xx) and Beta (with Xam.iOS 9.xx) and XamForms 1.4.4 and 1.5.0. Nothing helped.

    using System;

    using Xamarin.Forms;

    namespace ListViewBug2
    {
        public class App : Application
        {
            public App ()
            {

                ListView listview = new ListView();
                listview.ItemsSource = new String[]{"one","two","three"};
                listview.ItemTemplate = new DataTemplate(typeof (CustomCell));


                // The root page of your application
                MainPage = new ContentPage {
                    Content = new StackLayout {
                        VerticalOptions = LayoutOptions.Center,
                        Children = {
                            new Label {
                                XAlign = TextAlignment.Center,
                                Text = "Welcome to Xamarin Forms!"
                            },
                            listview,
                        },
                        Padding = new Thickness(0,20,0,0),
                    }
                };
            }

        }

        public class CustomCell : ViewCell {
            // Constructor
            public CustomCell() {
                Label myLabel = new Label();
                myLabel.Text = "custom list item";  // Hard code for now
                View = myLabel;
            }
        }
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>