Xamarin Forms Labs的图像大小、在图像按钮中的位置
我使用Xamarin Forms Labs创建了以下Xaml。图像太小,文本居中。我正在尝试将图像放大一点,但是ImageHeightRequest属性似乎没有任何影响。我还尝试了StackLayout格式的几种组合,例如仅对StackLayout和元素使用HorizontalOptions=“StartAndExpand”。这会导致按钮被挤压到左侧,宽度不足以显示按钮的整个文本。有没有人知道如何用更大的图像来实现这一点,并且所有的东西都与左边对齐?我知道图像更大,因为我正在将它从Windows Phone移植到Xamarin,同样的图像在Windows Phone上也更大。我还尝试使用常规的Xamarin Forms图像按钮,它可以渲染相同大小的图像Xamarin Forms Labs的图像大小、在图像按钮中的位置,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我使用Xamarin Forms Labs创建了以下Xaml。图像太小,文本居中。我正在尝试将图像放大一点,但是ImageHeightRequest属性似乎没有任何影响。我还尝试了StackLayout格式的几种组合,例如仅对StackLayout和元素使用HorizontalOptions=“StartAndExpand”。这会导致按钮被挤压到左侧,宽度不足以显示按钮的整个文本。有没有人知道如何用更大的图像来实现这一点,并且所有的东西都与左边对齐?我知道图像更大,因为我正在将它从Windows
<StackLayout Spacing="0" >
<Label>
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="My Label" ForegroundColor="#5C85FF" Font="Large"/>
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
<controls:ImageButton Text="Button 1" BackgroundColor="#5C85FF" TextColor="#ffffff" HeightRequest="90" WidthRequest="175" Image="Image1.png" Orientation="ImageToLeft" ImageHeightRequest="85" ImageWidthRequest="100" Clicked="ScanProductClicked" />
<controls:ImageButton Text="Button 2" BackgroundColor="#5C85FF" TextColor="#ffffff" HeightRequest="90" WidthRequest="175" Image="Image2.png" Orientation="ImageToLeft" ImageHeightRequest="85" ImageWidthRequest="100" Clicked="ShopProductsClicked" />
<controls:ImageButton Text="Button 3" BackgroundColor="#5C85FF" TextColor="#ffffff" HeightRequest="90" WidthRequest="175" Image="Image3.png" Orientation="ImageToLeft" ImageHeightRequest="85" ImageWidthRequest="100" Clicked="ShoppingListsClicked" />
<controls:ImageButton Text="Button 4" BackgroundColor="#5C85FF" TextColor="#ffffff" HeightRequest="90" WidthRequest="175" Image="Image4.png" Orientation="ImageToLeft" ImageHeightRequest="85" ImageWidthRequest="100" Clicked="LogInClicked" />
<controls:ImageButton Text="Button 5" BackgroundColor="#5C85FF" TextColor="#ffffff" HeightRequest="90" WidthRequest="175" Image="Image5.png" Orientation="ImageToLeft" ImageHeightRequest="85" ImageWidthRequest="100" Clicked="SettingsClicked" /> </StackLayout>
您可以通过使用TapGestureRecognitor使图像可点击来解决此问题。对于实施,请执行以下步骤:
你明白了吗?我放弃了
ImageButton
。相反,我决定使用Image
,并通过实现TapGestureRecognitizer
使其可点击。我认为最新的Xamarin.Forms使图像按钮可以开箱即用。Adam J Wolf有一篇关于这个主题的短文:。不幸的是,我不知道你对大小、位置等的控制有多大。谢谢大家的评论@乔:我试过了,但图片上的尺寸也不起作用。它看起来像是一个里面有图像的按钮。所以大小只是影响按钮,而不是图像