添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
光明磊落的玉米  ·  USAJOBS - Search·  2 月前    · 
玩足球的斑马  ·  行业动态·  5 月前    · 
慷慨大方的斑马  ·  Disney's Purchase of ...·  5 月前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account
  • an Image
  • a transparent Frame on top of the image
  • 2 buttons overlapping the transparent frame thanks to negative margins
  • Buttons should be on top of the frame, but they are beneath 😞

    Steps to Reproduce

    launch the sample here on Android:
    https://github.com/roubachof/Sharpnado.TaskLoaderView/tree/master/Retronado.Maui

    Navigate to "Commands/Snackbar" page.

    Version with bug

    6.0.408 (current)

    Last version that worked well

    Unknown/Other

    Affected platforms

    Android

    Affected platform versions

    Android

    Did you find any workaround?

    No response

    Relevant log output

    No response

    area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label Jul 26, 2022 s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Aug 1, 2022 legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Jan 6, 2023

    So, the reason this happens with Frame is that Frame retains some default Android Elevation behaviors from Forms for backward compatibility reasons. There are several ways you can work around this:

    You can use Border instead of Frame. Border doesn't have any intrinsic Elevation properties on Android, so it doesn't have this behavior:

    <Grid RowDefinitions="300,*">
        <Border ... />
        <Button Grid.Row="1" ZIndex="10" Margin="0,-20,100,0" ...  />
    </Grid>
    

    You can wrap the Frame inside of a ContentView; this will give the Frame a new context for its Elevation, preventing it from elevating above the other controls in the Grid's context:

    <Grid RowDefinitions="300,*">
        <ContentView>
            <Frame ... />
        </ContentView>
        <Button Grid.Row="1" ZIndex="10" Margin="0,-20,100,0" ...  />
    </Grid>
    

    You can force the Android Elevation property for the Frame to be zero using the Elevation platform-specific:

    <ContentPage ...            
    	xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
    	<Grid RowDefinitions="300,*">
            <Frame android:VisualElement.Elevation="0" ... />
            <Button Grid.Row="1" ZIndex="10" Margin="0,-20,100,0" ...  />
        </Grid>
    </ContentPage>
    

    Or you can disable the Frame's shadow:

    <Grid RowDefinitions="300,*">
        <Frame HasShadow="False" ... />
        <Button Grid.Row="1" ZIndex="10" Margin="0,-20,100,0" ...  />
    </Grid>
    

    You could also customize the handler and disable the backward-compatible Elevation handling.

    @hartez nice explanation! Your suggestions work like a charm. But the idea of MAUI is making one view for multiple platforms. Shouldn't this still considered as a bug?

    [EDIT]
    Only does this not fix having a shadow on my frame. Any suggestions?