来自图像对象的NativeScript全屏背景图像

时间:2016-08-04 21:50:28

标签: nativescript

我尝试在页面上放置图像,我需要将其拉伸到屏幕的整个宽度和高度(背景图像)。图像大于屏幕尺寸并且是正方形的,所以我需要它是屏幕的高度并居中。

我需要它作为图像,以便稍后移动它并为其设置动画。

到目前为止,我所能做的就是给我的页面一个背景图片:

File.WriteAllBytes("some.csv",ObjectToByteArray(items));

private byte[] ObjectToByteArray(Object obj)
     {
            if (obj == null)
                return null;

            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream ms = new MemoryStream();

            bf.Serialize(ms, obj);


            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            return encoding.GetBytes(ms.ToString());



        }

1 个答案:

答案 0 :(得分:0)

您的解决方案应该有效..但另一种可能的解决方法如下:

page.xml

pdf()

page.css

<Page>
    <GridLayout>
        <GridLayout id="background" scaleX="2" scaleY="2" />
        <!-- page content follows here -->
    </GridLayout>
</Page>     

使用相应的比例来拉伸图像,然后您可以在此处轻松为背景图像设置动画。 e.g。

#background {
  background-image: url("path-to-image");
}