SuaveControls.MaterialFormControls icon indicating copy to clipboard operation
SuaveControls.MaterialFormControls copied to clipboard

How to apply a shadow effect on Android for the MaterialButton?

Open pcdus opened this issue 6 years ago • 4 comments

Hello, I use the MaterialButton on an app.

The shadow is well applied on iOS, but not on Android.

I first apply a style on the MaterialButton:

<Style x:Key="LightButton" TargetType="ctrl:MaterialButton">
   <Setter Property="FontFamily" Value="{StaticResource MontserratFont}" />
   <Setter Property="FontSize" Value="12" />
   <Setter Property="BorderRadius" Value="0" />
   <Setter Property="TextColor" Value="#EA3024" />
   <Setter Property="BackgroundColor" Value="#FFFFFF" />
</Style>

Then I use it like this in my pages:

<ctrl:MaterialButton Style="{StaticResource FncLightButton}" 
                                   Elevation="4"
                                   Text="ANNULER
                                   Command="{Binding CancelCommand}"
                                   Margin="0, 0, 10, 0">

Is it normal? How should I achieve this?

pcdus avatar Aug 24 '18 09:08 pcdus

Is your Android Theme set to something inheriting from AppCompat?

SuavePirate avatar Aug 24 '18 13:08 SuavePirate

Yes the main theme inherits from AppCompat:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MainTheme" parent="MainTheme.Base">
    </style>
    <!-- Base theme applied no matter what API -->
    <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
        <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
        <item name="windowNoTitle">true</item>
        ...
    </style>
    <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">#FF4081</item>
    </style>
</resources>

pcdus avatar Aug 24 '18 14:08 pcdus

What version of Xamarin.Forms and did you call the renderer init?

SuavePirate avatar Aug 24 '18 14:08 SuavePirate

I use the latest "stable" version of Xamarin.Forms and I have well called the renderer init. I will create a new sample project to reproduce this issue.

pcdus avatar Aug 27 '18 08:08 pcdus