xaml - 按钮图标不显示 xamarins 表单 xaml
问题描述
我是 xaml 的新手,我有一个问题。我正在尝试在 xamarin.forms 中的文本旁边创建一个带有图标的按钮。但是当我试图显示它时,我的应用程序上什么都没有。添加 png 图标。图像位于Ressources->drawable
文件夹中。这是 xaml 代码。
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="epicture.MainPage">
<StackLayout>
<Button Text="Log in" ImageSource="login.png" Clicked="Button_Clicked" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" BackgroundColor="#00c851" TextColor="White"></Button>
<WebView Navigating="WebView_Navigating"></WebView>
</StackLayout>
</ContentPage>
解决方案
我也面临同样的问题 ImageButton 没有文本属性。因此,我创建了带有文本属性的自定义 ImageButton 控件,您可以参考这可能会对您有所帮助。
https://xamarincodingtutorial.blogspot.com/2019/05/step-to-create-imagebutton-with-text.html
推荐阅读
- python - 使用代理时远程结束关闭连接而无响应
- elasticsearch - 如何加快节点之间的数据传输到我的 Elasticsearch 集群
- python - CreateProcessW 失败错误:2 posix_spawn:没有这样的文件或目录
- gcc - 为什么 -D_FORTIFY_SOURCE=2 在我的编译中没有影响?
- google-analytics - 谷歌数据洞察报告表现
- javascript - JS 注销Facebook App后,.getLoginStatus 仍然返回“已连接”
- r - 将 geojson 转换为 sf 以获取 clotopleth 地图
- python - 从较大的字符串中删除字符并重新添加字符,但确保不使用相同的无效字符
- python - 使用 google sheet API 使第一行变为粗体
- sumologic - 搜索结果的 Sumologic 图