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

Adjust Z-Index of a view in AbsoluteLayout

$
0
0

I want to bring an overlay with a Label above contents in the page. This is what I have tried.

            `var pageContent = new AbsoluteLayout();
                var content = new StackLayout(){BackgroundColor=Color.Blue,HeightRequest=100,WidthRequest=100,Children={new Label(){Text="BackGround content in Red color. This portion will now hold the cards",TextColor=Color.Red}}};
                var overlayout= new AbsoluteLayout(){BackgroundColor=Color.FromRgba(255,0,0,50)};
                AbsoluteLayout.SetLayoutFlags(overlayout, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(overlayout, new Rectangle(0.0, 0.0, 320, 400));
                var textMessage = new Label(){Text="Test Overlay"};
                AbsoluteLayout.SetLayoutFlags(content, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(content, new Rectangle(0f, 0f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
                AbsoluteLayout.SetLayoutFlags(textMessage, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(textMessage, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
                overlayout.Children.Add(textMessage);
                pageContent.Children.Add(content);
                pageContent.Children.Add(overlayout);`

pageContent is the Content of the ContentPage set as MainPage. Content is the contents of the pageContent. overLayout is the layout of the overlay. Content is appearing above overLayout. Even if I swap the lines that adds content and overlayout , the result is the same. How can I have overlayout over Content ?

Also Color.FromRgba(255,0,0,50) does not seem to be transparent. 50 alpha means 50/255 transparency right ?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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