0
votes

I used to use the Frame control of Xamarin.Forms as a CardView for Android, but I updated the Xamarin.Forms package to version 3.1.0 and the frame appearence has changed. It doesn't have elevation and shadows. I tried to create a custom renderer, but doesn't work.

To explain what I'm trying to say, see the pictures below. First picture is the old behaviour of frame. The appearence is exactly like CardView in Android and the second picture is the new behaviour, for the version 3.1.0 of Xamarin.Forms. The frame doesn't have elevation and shadows.

Old behaviour:

enter image description here

New behaviour

enter image description here

Here is my code that I use the Frame (for Android Platform, CardView is a simple frame)

<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
In code you have write anything?Srusti Thakkar
@SrustiThakkar in Android platform, is just a frame, with default values for properties. I will edit the question to put my code and you will see "CardView", but CardView inherits from Frame and have changes only for iOS. For Android, is just a FrameVinícius da Cruz Maia
Why don't you give it shadow and elevation from xaml?FreakyAli
I think there is no need to create custom control like CardView. You can also use Frame directly.Srusti Thakkar

1 Answers

0
votes
<Frame HasShadow="true">
<Label Text="Test"/
</Frame>

I guess after Update default value for HasShadow in Frame is set to false;