小编Joo*_*pel的帖子

Xamarin以编程方式在底部形成垂直对齐图像

在(相对)新的Xamarin表单中,我试图将图像垂直对齐到滚动视图的底部.

这是我的代码,这正是我想要的(对于滚动的大图像).但是当我的图像小于设备的高度时,它应该对准屏幕的底部,而不是屏幕的中心(可能是默认值).由于文档(仍然)缺乏,我如何在代码中实现这一点?

return new ContentPage {
    Content = new ScrollView {
        Orientation = ScrollOrientation.Vertical,
        BackgroundColor = Color.Black,
        Content = new Image {
            Source = ImageSource.FromFile (image)
        }
    }
};
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这个,但它给出了一个错误,即以下方法或属性之间的调用是不明确的...

RelativeLayout rl = new RelativeLayout ();
rl.Children.Add (new ScrollView {
    Orientation = ScrollOrientation.Vertical,
    BackgroundColor = Color.Black,
    Content = new Image {
        Source = ImageSource.FromFile (image)
    }
});

return new ContentPage {
    Content = rl
};
Run Code Online (Sandbox Code Playgroud)

xamarin xamarin.forms

0
推荐指数
1
解决办法
5471
查看次数

标签 统计

xamarin ×1

xamarin.forms ×1