1

android 上的XlabsGridView不显示相对或堆栈布局。但它的工作正常iOS。如果我在“cell.View”中设置img它在两个平台上都可以正常工作,但是如果我在“cell.View”中设置任何布局,GridView在 Android 上只显示背景颜色,iOS一切都很好,有人可以帮忙吗?

GridImage.ItemTemplate = new DataTemplate (() => {
var rel = new RelativeLayout ();

            var img = new Image () {
                Aspect = Aspect.AspectFill,
            };
            img.SetBinding (Image.SourceProperty, ".", converter: new FilterToImageSourceConverter ());
            var label = new Label () {
                TextColor = Color.White,
                FontSize = 20,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center
            };
            label.SetBinding (Label.TextProperty, ".", converter: new FilterToLabelTextConverter ());

            label.GestureRecognizers.Add (new TapGestureRecognizer ((sender, e) => {
                ItemClicked ();
            }));

            rel.Children.Add (img,
                Constraint.RelativeToParent ((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return parent.Width;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return parent.Height;
                })
            );

            rel.Children.Add (label,
                Constraint.RelativeToParent ((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return parent.Width;
                }),
                Constraint.RelativeToParent ((parent) => {
                    return parent.Height;
                })
            );
            var cell = new ViewCell ();
            cell.View = rel;
            return cell;
        });
4

0 回答 0