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

Center image and text on button

$
0
0

Is there a way to center the text and image on a button? I want the image to be on top and text below, both centered on button.
I'm trying to use a custom renderer on android like this

class MenuButtonRenderer: ButtonRenderer
{   
    protected override void OnElementChanged (ElementChangedEventArgs<Xamarin.Forms.Button> e)
    {
        base.OnElementChanged (e);
        if (e.OldElement == null) {   // perform initial setup
            var nativeButton = (global::Android.Widget.Button)Control;
            nativeButton.Gravity = (global::Android.Views.GravityFlags.CenterHorizontal | global::Android.Views.GravityFlags.CenterVertical);
            nativeButton.SetPadding (20, 30, 0, 0);
        }
    }
}

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>