Custom Button Text Alignment

Nathan Sokalski 4,121 Reputation points
2021-03-16T19:49:45.377+00:00

I have a Button in Xamarin.Android, and I need to offset the text content from it's default position. My first thought was to use paddingTop & paddingBottom, but the Button seems to ignore them. Why is the Button ignoring paddingTop & paddingBottom, and how can I offset/position the text content of my Button? Thanks.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-17T08:48:49.4+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Test with the following simple code , it work fine .

       <Button  
               android:text="abc"  
               android:layout_width="200dp"  
               android:layout_height="200dp"  
               android:paddingBottom="100dp"  
               />  
    

    78686-capture.png

    I suspect you set the same value on paddingTop & paddingBottom , in this cause the text position would not change .


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.