xamarin - 以 xamarin 形式格式化按钮文本和图像
问题描述
我想格式化文本和图像,就像附加的图像一样。如何使文本居中并将左侧带有一点填充的图像放在一边?
<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>
解决方案
而不是一个按钮,我只会使用一个布局控件来组成你想要的布局,并将一个 TapGestureRecognizer 附加到它上面
我将使用嵌套的 StackLayouts 进行说明,但这可能更适合使用 Grid 代替
<StackLayout Orientation="Horizontal" >
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="MyTappedHandler" />
<StackLayout.GestureRecognizers>
<Image ... />
<StackLayout>
<Label ... />
<Label ... />
</StackLayout>
</StackLayout>
推荐阅读
- tensorflow - Tensorflow:ValueError:`generator`产生了一个形状()的元素,其中一个形状()的元素是预期的
- php - Wordpress 更改回复链接
- azure - 如何获取未连接到 Log Analytics Worspace 的 VMS 列表?
- python - SQLAlchemy 动态 column_property
- javascript - Netconf librarr - JS 中的 RPC 请求
- python - 在本地从 pyspark 读取 azure datalake gen2 文件
- flutter - 导航时颤振菜单不会覆盖主菜单
- django - 在 Django 模板上同时运行两个列表
- bootstrap-4 - Y-滚动 flex 容器内的两个 flex 容器
- javascript - 如何在 Pills Bootstrap 中显示 URL