Does the concept of z-index? The picture shows that there is no overlap. How to set z-index? the top two custom select box
<AbsoluteLayout Padding="10,10,10,10" VerticalOptions="FillAndExpand"> <ui:BoxSelector x:Name="selectorExchangs" AbsoluteLayout.LayoutBounds="0,0,0.5,0.3" AbsoluteLayout.LayoutFlags="All" BackgroundColor="Transparent" CommandAfterChanged="{Binding ExchangesAfterChangedCommand}" Items="{Binding ExchangesList}" LabelPath="Name" PanelColor="#f9f9f9" SelectedItem="{Binding SelectedExchange}" SelectorLabel="EXCHANGE" /> <ui:BoxSelector AbsoluteLayout.LayoutBounds="1,0,0.5,0.3" AbsoluteLayout.LayoutFlags="All" BackgroundColor="Transparent" CommandAfterChanged="{Binding TradingPairAfterChangedCommand}" Items="{Binding AvailableTradinPairsList}" LabelPath="PriceCurrencyName" PanelColor="#f9f9f9" SelectedItem="{Binding SelectedTraingPair}" SelectorLabel="CURRENCY" />
And all the rest. Chart, data, e.t.c
<StackLayout AbsoluteLayout.LayoutBounds="1,1,1,0.9" AbsoluteLayout.LayoutFlags="All">...</StackLayout>
BoxSelector.xaml(content view), Reusable ContentView extends
<ContentView.Resources> <ResourceDictionary x:Name="AppDictionary"> <Color x:Key="BackgroundColor">#f9f9f9</Color> <Color x:Key="BorderColor">#e2e2e2</Color> <Style x:Key="InternalViewStyle" TargetType="ContentView"> <Setter Property="BackgroundColor" Value="{StaticResource BackgroundColor}" /> <Setter Property="VerticalOptions" Value="Fill" /> <Setter Property="Padding" Value="5,5,5,5" /> </Style> <Style x:Key="BorderStyle" TargetType="ContentView"> <Setter Property="BackgroundColor" Value="{StaticResource BorderColor}" /> <Setter Property="Padding" Value="1,1,1,1" /> </Style> </ResourceDictionary> </ContentView.Resources> <StackLayout BindingContext="{x:Reference Name=ContentView}" HorizontalOptions="FillAndExpand"> <ContentView BackgroundColor="#f5f5f5" HorizontalOptions="FillAndExpand"> <StackLayout> <ContentView Style="{StaticResource BorderStyle}"> <ContentView Style="{StaticResource InternalViewStyle}"> <StackLayout Orientation="Horizontal"> <StackLayout x:Name="selectorBox" BackgroundColor="{Binding PanelColor}" HorizontalOptions="FillAndExpand" Orientation="Horizontal"> <StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal"> <Label FontSize="12" HorizontalOptions="FillAndExpand" Text="{Binding SelectorLabel}" TextColor="#cccccc" /> <Label x:Name="valueLabe" BackgroundColor="{Binding PanelColor}" FontSize="13" HorizontalOptions="FillAndExpand" Text="Choose" TextColor="#313131" /> </StackLayout> <StackLayout HorizontalOptions="EndAndExpand"> <Label Text="+" TextColor="#313131" /> </StackLayout> </StackLayout> </StackLayout> </ContentView> </ContentView> <Grid x:Name="boxSelectorGrid" BackgroundColor="#f5f5f5" Padding="10,10,10,10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> </Grid> </StackLayout> </ContentView> </StackLayout>
In Android, you will not encounter the keyboard-sliding up issue because by default the UI moves up when the keyboard appears on your screen. This is not the case with iOS. In iOS, you have to manually fix the overlapping keyboard whether it is Xamarin.iOS, Xamarin Forms, or even iOS on the XCode.
Reacting to Changes in Orientation. Xamarin.Forms does not offer any native events for notifying your app of orientation changes in shared code. However, the SizeChanged event of the Page fires when either the width or height of the Page changes. When the width of the Page is greater than the height, the device is in landscape mode.
It is called Xam.Plugins.Forms.KeyboardOverlap Here’s how to use it. The first step is to right-click on your iOS project. Then go to Manage NuGet Packages. On the browse tab, type keyboardoverlap.
To detect orientations without Xamarin.Essentials, monitor the SizeChanged event of the Page, which fires when either the width or height of the Page changes. When the width of the Page is greater than the height, the device is in landscape mode. For more information, see Display an Image based on Screen Orientation.
Z-Index is established by the ordering of the Child elements in a container element. The first child is at the back of the Z stack, the second child is placed above it, and so on.
The layout container you are using will dictate how each child is positioned. A StackLayout
will not allow overlaps. AbsoluteLayout
and RelativeLayout
will allow overlaps easily. A Grid
will allow overlap for elements that extend into the same row and column. None of these have an appearance of their own (think of them as transparent boxes by default). If you want them to occlude the content behind them, then you will need to assign a background color or image, else they will just be painted right on top of the other content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With