Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set form Background as transparency in portable cross platform xamarin form?

I am using Portable xamarin cross platform. I have two project android and IOS.

I have to make form as transparent form. I have written code for same and this code perfectly working in android but not in IOS

Below is my code:

  <ContentPage BackgroundColor="#00000000">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="180"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="200"></RowDefinition>
            </Grid.RowDefinitions>

            <StackLayout Grid.Row="0" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor="#80000000" HeightRequest="175" >

            </StackLayout>

            <BoxView HeightRequest="200" Grid.Row="1"></BoxView>

            <StackLayout VerticalOptions="End" HorizontalOptions="FillAndExpand"  BackgroundColor="#80000000" HeightRequest="160"  Grid.Row="2" >
                <Label Text="05:00" FontSize="60" FontAttributes="Bold" TextColor="White" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" ></Label>
            </StackLayout>
        </Grid>  

   </ContentPage>

Below is android Screen shot:

enter image description here

Below is IOS ScreenShot :

enter image description here

Please suggest me what to do to have transparency form in both platform

Thanks in advance

like image 645
Kirti Zare Avatar asked Sep 21 '16 10:09

Kirti Zare


2 Answers

Even simpler solution would be to just change the hex values of the alpha channel.

FBC1BC is a solid color but #00FBC1BC is a transparent, due to 00 which set the alpha of the color to 0 or transparent.

So just do this #FBC1BC > #50FBC1BC

And you will get a transparent background color with alpha defined by the first two values!

like image 70
Tarik Ćosović Avatar answered Sep 17 '22 01:09

Tarik Ćosović


SIMPLE AS THIS

BackgroundColor = Color.Transparent

OR in xaml

 `<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="XXX.Core.Views.Pages.XXXX.XXXX"
         xmlns:local="clr-namespace:XXX.Core.Views.CustomControls"    
         BackgroundColor="Transparent">`
like image 21
Nathan Smiechowski Avatar answered Sep 19 '22 01:09

Nathan Smiechowski