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

Cannot fully extend the background image.

$
0
0

I have an unusual padding on my entire layout on the android player. The background image should fully extend but instead, it didn't.

public class HomeScreen : ContentPage
{
public HomeScreen ()
{
// provide the heading label
var headingLabel = new MyLabel {
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center,
Text = "GameStore",
FontFamily = Device.OnPlatform (
"Money Money",
"Money Money",
null),
FontSize = Device.OnPlatform (42,45,99)

        };

        var layout = new StackLayout();

        layout.Children.Add (headingLabel);

        // provide the background image
        var homeScreenImage = new Image {Aspect = Aspect.Fill };

        homeScreenImage.Source =  Device.OnPlatform(
            ImageSource.FromFile("home_background.jpg"),
            ImageSource.FromFile("home_background.jpg"),
            null);


        // merge views and create a layout
        var relativeLayout = new RelativeLayout ();

        relativeLayout.Children.Add(homeScreenImage,
            Constraint.RelativeToParent (
                ((parent)=>{return 0;})
            ));

        relativeLayout.Children.Add(layout,
            Constraint.RelativeToParent((parent) => {return parent.Width/13;} ),
            Constraint.RelativeToParent((parent) => {return parent.Height/3;} ));


        Content = relativeLayout;

    }

Viewing all articles
Browse latest Browse all 58056

Trending Articles