以Xamarin形式设置按钮文本和图像的格式

时间:2018-11-07 01:54:45

标签: xamarin xamarin.forms

我想设置文本和图像的格式,就像附加的图像一样。 我如何才能居中放置文本,并在图像的左侧到左侧放置一些填充?

<Button StyleClass="btnFAF" Text="Field Activity" Image="icon.png" Grid.Row="0" Grid.Column="0" x:Name="btnFAF" Clicked="btnFAF_Clicked" BorderRadius="6">
    <Button.FontFamily>
        <OnPlatform x:TypeArguments="x:String">
            <On Platform="Android" Value="OpenSans-Regular.ttf#OpenSans-Regular"/>
        </OnPlatform>
    </Button.FontFamily>
</Button>

Format I want

1 个答案:

答案 0 :(得分:0)

代替按钮,我只需要使用Layout控件组成所需的布局,并将TapGestureRecognizer附加到

我将用嵌套的StackLayouts进行说明,但这可能更适合于使用Grid

<StackLayout Orientation="Horizontal" >
  <StackLayout.GestureRecognizers>
    <TapGestureRecognizer Tapped="MyTappedHandler" />
  <StackLayout.GestureRecognizers>
  <Image ... />
  <StackLayout>
    <Label ... />
    <Label ... />
  </StackLayout>
</StackLayout>