Xamarin在iOS上形成带有文本和矢量图像的按钮

时间:2017-11-02 15:34:21

标签: c# ios xamarin xamarin.forms

在我的Xamarin.Forms PCL项目中,我试图创建一个按钮,其中的文字显示在图像下方。但是一旦我添加图像(这是一个矢量图像 - 并且无法指定大小?) - 文本就会消失。仅显示图像。

关于图像显示时文本消失的想法?

我的代码:

<?xml version="1.0" encoding="UTF-8"?>
<Button xmlns="http://xamarin.com/schemas/2014/forms" 
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="MyProj.Views.ToolbarButtonView"
        Text="hello" 
        Image="myvectorimage" 
        ContentLayout="Top,1" >
</Button>

我很感激帮助!

1 个答案:

答案 0 :(得分:1)

Here(Kevin)是解释Button上图像和文字的更好答案。

我认为最好使用StackLayout(添加TapGesture)与Image和Label而不是Button。它更可控。