Transparent Page In Xamarin.forms
I need to be able to create a transparent Xamarin.Forms page for Android. How can I do this true a page renderer? Now it has a default background color. [assembly: ExportRenderer(t
Solution 1:
If you just want to make your page's background transparent, you don't need to create a custom renderer for this. You can set the background color in PCL.
For example, xaml:
<ContentPagexmlns="http://xamarin.com/schemas/2014/forms"xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"xmlns:local="clr-namespace:NameSpace"x:Class="NameSpace.MainPage"BackgroundColor="Transparent"></ContentPage>
Or in code behind:
publicpartialclassMainPage : ContentPage
{
publicMainPage()
{
InitializeComponent();
this.BackgroundColor = Color.Transparent;
}
}
To prove it's transparent, we can use a NavigationPage
with colored background for testing in App.xaml.cs
:
publicApp()
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage())
{
BackgroundColor = Color.Red
};
}
Post a Comment for "Transparent Page In Xamarin.forms"