代码之家  ›  专栏  ›  技术社区  ›  Vinícius da Cruz Maia

Xamarin表单-更新Xamarin表单版本后的框架更改

  •  0
  • Vinícius da Cruz Maia  · 技术社区  · 6 年前

    要解释我想说的话,请看下面的图片。第一张照片是帧的旧行为。其外观与Android中的CardView一模一样,第二张图片是Xamarin.Forms 3.1.0版的新行为。框架没有立面和阴影。

    老行为:

    enter image description here

    新行为

    enter image description here

    这是我使用框架的代码(对于Android平台,CardView是一个简单的框架)

    <customViews:CardView>
                        <StackLayout Spacing="0">
                            <StackLayout.Margin>
                                <OnPlatform x:TypeArguments="Thickness" Android="16"/>
                            </StackLayout.Margin>
                            <ContentView>
                                <OnPlatform x:TypeArguments="View">
                                    <OnPlatform.iOS>
                                        <customViews:HeaderDivider/>
                                    </OnPlatform.iOS>
                                </OnPlatform>
                            </ContentView>
    
    public class CardView : Frame
        {
            public CardView()
            {
                Padding = 0;
    
                if (Device.RuntimePlatform == Device.iOS)
                {
                    HasShadow = false;
                    OutlineColor = Color.Transparent;
                    BackgroundColor = Color.Transparent;
                }
            }
        }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Woj    6 年前
    <Frame HasShadow="true">
    <Label Text="Test"/
    </Frame>
    

    我猜更新后的默认值为hassadow in Frame设置为false;