【问题标题】:Xamarin Forms - Frame change after update Xamarin Forms versionXamarin Forms - 更新 Xamarin Forms 版本后的框架更改
【发布时间】:2019-01-17 07:48:54
【问题描述】:

我以前使用 Xamarin.Forms 的 Frame 控件作为 Android 的 CardView,但我将 Xamarin.Forms 包更新到版本 3.1.0,并且框架外观发生了变化。它没有高程和阴影。我尝试创建自定义渲染器,但不起作用。

要解释我想说的话,请看下面的图片。第一张图片是框架的旧行为。外观与 Android 中的 CardView 完全相同,第二张图片是 Xamarin.Forms 版本 3.1.0 的新行为。框架没有高程和阴影。

旧行为:

新行为

这是我使用框架的代码(对于 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;
            }
        }
    }

【问题讨论】:

  • 在代码中你写过什么吗?
  • @SrustiThakkar 在 Android 平台中,只是一个框架,属性有默认值。我将编辑问题以放置我的代码,您将看到“CardView”,但 CardView 继承自 Frame,并且仅针对 iOS 进行了更改。对于Android,只是一个Frame
  • 你为什么不从 xaml 给它阴影和高程?
  • 我认为没有必要像 CardView 那样创建自定义控件。你也可以直接使用Frame。

标签: xamarin xamarin.forms xamarin.android


【解决方案1】:
<Frame HasShadow="true">
<Label Text="Test"/
</Frame>

我猜在 Frame 中的 HasShadow 的 Update 默认值设置为 false 之后;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-23
    • 2021-04-20
    • 1970-01-01
    • 2017-06-05
    • 2016-10-03
    • 2016-09-24
    相关资源
    最近更新 更多