Reputation: 535
I am simply displaying an Image
on my Xamarin Forms
page. The image is transparent and this is how it displaying on page:
How can I remove those white and grey background? This is my source code:
<ContentPage.Content>
<StackLayout>
<Image x:Name="myimage" Aspect="Fill">
</Image>
</StackLayout>
</ContentPage.Content>
Code-behind
myimage.Source = ImageSource.FromResource("RailwayApp.bull.jpg");
My try:
I tried setting IsOpaque
property to True/False
neither worked. Also declared BackgroundColor="Transparent"
on XAML
page but not worked.
Upvotes: 1
Views: 3273
Reputation: 39102
In this case you can't, the background is actually not transparent - it would have to be a transparent PNG or GIF to support this. This is a JPG, so the background is actually grey and white.
To make this work you will first have to actually make the image transparent by converting in one of the two transparent formats (and actually remove the background) and then it should display as transparent as expected.
Upvotes: 3