I created a new xamarin forms project with .NET Standard 2.0 and in the sample i changed the label to Button and added the background color. While the button is clicked the ripple animation is shown small and concentrated to the top left corner and not the entire button width and height
<Button Text="Welcome to Xamarin.Forms!" HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" BackgroundColor="Lime" />
Is there anything we need to do to make the ripple animation correct.
Please see the image attached.
If you want to remove the extra tint animation part. Then you have to write custom render class for Button in Android platfrom. Please check the sample code
assembly: ExportRenderer(typeof(TintableButton), typeof(TintableButtonRenderer))]
namespace XamTest.Droid.Renderers
{
public class TintableButtonRenderer : ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
var control = e.NewElement as TintableButton;
if (control != null)
{
if (control.TintColor != Xamarin.Forms.Color.Default)
{
var androidColor = control.TintColor.ToAndroid();
Control.Background.SetColorFilter(androidColor, PorterDuff.Mode.Src);
}
}
}
}
}
Call this custom control in UI.
<Grid>
<controls:TintableButton Text="Test" HorizontalOptions="FillAndExpand" />
</Grid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With