Teask Nick
Teask Nick

Reputation: 69

Background image on relative layout don't get the screen size on forms

This is the code of the image and layout from a tabbed page:

RelativeLayout PrincipalLayout = new RelativeLayout ();

                Image background = new Image {
                    Source = Images.Background,
                };

                PrincipalLayout.Children.Add (background,
                    xConstraint: Constraint.RelativeToParent ((parent) => {
                        return 0;
                    }),
                    yConstraint: Constraint.RelativeToParent ((parent) => {
                        return 0;
                    }),
                    widthConstraint: Constraint.RelativeToParent ((parent) => {
                        return parent.Width;
                    }),
                    heightConstraint: Constraint.RelativeToParent ((parent) => {
                        return parent.Height;
                    })
                );
this.Content = PrincipalLayout;

But the image don't start at X = 0 and don't finish at the right place.

Take a look at the image:

http://i292.photobucket.com/albums/mm15/romuloviel/Captura%20de%20Tela%202015-03-18%20as%2010.06.34_zpsb4cquhtd.png

I need the image get all frame.

Upvotes: 0

Views: 1925

Answers (1)

JordanMazurke
JordanMazurke

Reputation: 1123

The default aspect for an Image object is AspectFit - this could result in some letter boxing.

See the documentation for alternative aspects that may better display your image:

http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.Aspect

Upvotes: 1

Related Questions