1 回答
TA贡献1829条经验 获得超7个赞
回答
HeightRequest
不能保证,这只是一个请求。如果 Xamarin.Forms 能够满足请求,它会执行它,但根据屏幕大小和布局,它可能无法满足请求。
解决方案
设置Grid.ColumnDefinition
'sWidth
和Grid.RowDefinition
'sHeight
的值。
代码
<Grid Margin="1" Padding="0" ColumnSpacing="0" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="17" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="17" />
<ColumnDefinition Width="17" />
<ColumnDefinition Width="17" />
</Grid.ColumnDefinitions>
<BoxView CornerRadius="3" Color="LightGray" Grid.Row="0" Grid.Column="0"/>
<BoxView Margin="1" CornerRadius="3" BackgroundColor="White" Grid.Row="0" Grid.Column="1"/>
<StackLayout Margin="2,0,2,0" Orientation="Horizontal" Spacing="0" Grid.Row="0" Grid.Column="2">
<Image Source="hooray_icon"
Margin="1,0,1,0"
Aspect="Fill"
HeightRequest="16"/>
<Label Text="{Binding HoorayCount}"
Margin="1,0,1,0"
VerticalOptions="Center"
VerticalTextAlignment="Center"
HorizontalOptions="Center"
HorizontalTextAlignment="Center"
HeightRequest="16"/>
</StackLayout>
</Grid>
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报