如何在图像按钮内为源图像填充?
更新:
<ImageButton Source="cell_arrow_right.png" IsVisible="{Binding IsNotLeaf}"
VerticalOptions="Center" HorizontalOptions="Center"
WidthRequest="40" HeightRequest="40" Aspect="Fill"
Clicked="ImageButton_Clicked" Margin="0, 0, 15, 0"
BackgroundColor="Transparent" BorderColor="Accent"
BorderWidth="1" Scale="0.9" CornerRadius="5" />
我尝试使用Padding
,但不起作用。它只是移动源图像。我也尝试编辑margin
-仍然没有结果。
现在,我刚刚编辑了图像本身,并使用了填充。但这是一个错误的决定。.(
答案 0 :(得分:1)
我怀疑问题实际上是HorizontalOptions
和VerticalOptions
,它们都设置为Center
,这会将ImageButton
放置在其包含元素的中心。
请尝试将其完全删除(它们的默认值为HorizontalOptions=Fill
,垂直格式相同)。或者您可以尝试:
<ImageButton VerticalOptions="Start" HorizontalOptions="Start" Margin="10" />
这将在ImageButton
周围留出10的边距,并将图像放置在其包含元素的开头(水平和垂直,即顶部和左侧)。
填充表示元素与其子元素之间的距离。
边距表示一个元素与相邻元素之间的距离。
有一个很好的指南here。