Forum Xamarin Xamarin.Forms

absolutelayout image to be aspect="fill" but resizes

ManhaoChenManhaoChen NZMember ✭✭
edited September 2016 in Xamarin.Forms

hi trying to setup a background image

initially i had the back ground image setup on the page itself, but it wasn't working as the page was resizing the image when the keyboard appears.

i've been reading to use the absolute layout which my page now looks like

<AbsoluteLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <Image AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" Aspect="AspectFill"> <Image.Source> <OnPlatform x:TypeArguments="ImageSource" Android="splash.png" /> </Image.Source> </Image> <ContentView x:Name="cvContent" Padding="0" AbsoluteLayout.LayoutBounds="0,1,1,0.6" AbsoluteLayout.LayoutFlags="All" /> </AbsoluteLayout>

when the keyboard appears, my background image does not get resized,

but i need the but i need the image to display like the property Aspect="Fill"
anyway i could play with the LayoutBounds and set to resize/fit into the page 100% scaled and not cropped?

code for startup
` public class MainActivity : Xamarin.Forms.Platform.Android.FormsApplicationActivity
protected override void OnCreate(Bundle bundle)

  Xamarin.Forms.Forms.Init(this, bundle);

  // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window

  //status/navigation bar colour manipulation not supported below api v21
  if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
    // set color for status bar
    Window.SetStatusBarColor(Color.Rgb(22, 43, 66));
    // set color for navigation bar
    Window.SetNavigationBarColor(Color.Rgb(25, 49, 77));

  // don't make app full screen

  // keyboard appearing will resize input screen

  ActionBar.SetIcon(new Android.Graphics.Drawables.ColorDrawable(Android.Graphics.Color.Transparent));
  LoadApplication(new App());


Sign In or Register to comment.