Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How To Create A Floating Action Button In Xamarin.Forms

$
0
0

I needed to do this myself, and most of the solutions I found were either outdated or I found them unacceptable. Some of them led me in the right direction, though. So I figured I would share what I found. It's actually not all that difficult to do.

<?xml version="1.0" encoding="utf-8"?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Namespace.Class">
    <AbsoluteLayout>
        [Your ListView or other content goes here]

        <Button WidthRequest="56" HeightRequest="56" CornerRadius="28" Margin="10"
                AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="1.0,1.0,-1,-1"
                Image="[Put the image you would like to use for your icon here]"
                Command="{Binding [Command to be called on click]}" />
    </AbsoluteLayout>
</ContentPage>

This creates a floating action button that follows the material design guidelines and looks like it belongs on Android.


Viewing all articles
Browse latest Browse all 77050

Trending Articles