Reputation: 976
I have an Image file that i create during runtime.
I want to set it as backgroundImage of a ContentPage (in android project)
I tried to set the path of the file to the BackgroundImage property but it doesn't work.
Is there a way to do it ?
I can't put it as resource since I create it at runtime
Upvotes: 0
Views: 401
Reputation: 4321
I think that documentation is out of date. Becuase target Android has more than one resources. as /drawable-hdpi /drawable-xhdpi etc.
So you should add your images for all folders because it will work device. It Works.
*but I think that main issue on Xamarin.Forms Becase drawable folder have to default images source when system couldn't find special resolution must select from default folder... *
Upvotes: 0
Reputation: 3698
Put your page into Grid
which first element is an Image
, then set that image Source
to your stream like:
Image bgImage = new Image
{
Source = ImageSource.FromStream(() => { return new MemoryStream(buffer); });
}
Grid mainGrid = new Grid
{
Children = {bgImage,yourContent}
};
yourPage.Content= mainGrid;
Upvotes: 0