我对Xamarin移动设备非常陌生。如何制作一个具有百分比尺寸的框,使其左侧包含方形图片,右侧包含文本,并且整个实体都像按钮一样易于触摸?更好的是,孩子们在右侧要垂直堆叠。所要求的具体配置完全是任意的,只是参考示例。
答案 0 :(得分:1)
有很多方法可以做到,这是通过Grid
向我添加了TapGestureRecognizer
的一种方法。
<Grid BackgroundColor="Gray">
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="Handle_Tapped" />
</Grid.GestureRecognizers>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Source="deli.jpg" Margin="5,5,5,5" Aspect="AspectFill" Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" />
<StackLayout BackgroundColor="Black" Orientation="Vertical" Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" VerticalOptions="CenterAndExpand">
<Label Text="Cured" TextColor="White" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" />
<Label Text="Meat" TextColor="White" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" />
<Label Text="(View More)" TextColor="White" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" />
</StackLayout>
</Grid>