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

Setting BackgroundImage On Page for Different Platforms

$
0
0

I've got a quick question on setting a Background Image on a Content Page.

So I've created a ContentPage and I've see that it has a BackgroundImage property that I would like to use. This page will use a *.png as a background image. I can set it by:

BackgroundImage = "mybackground.png"

Which is fine and dandy, however, I would like to load the tall 568h images if the phone is in a tall form factor, or load the landscape image if it's on the iPad. And on the Android side, I'd like to load a slightly different version of the image.

Other than putting a bunch of #if statements checking to see which platform I'm on, is there any best practice to doing this. I would really like to avoid something like this all over the place:

#if __IOS__
  using MonoTouch.UIKit;
#endif

#if __iOS__
  if(UIScreen.MainScreen.Bounds.Height >= 568)
  {    
        BackgroundImage = "mybackground-568h.png";
  }
  else
  {
        BackgroundImage = "mybackground.png";
  }
#endif
#if __ANDROID__
   //etc etc
#endif

Anyone have any suggestions??


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>