我想将图标放置在框架的右上角。 我必须承认我多次阅读了绝对布局,但是显然没有想到。
从图片中可以看到,图标有点破了,这就是代码
示例代码有误!
<AbsoluteLayout>
<Frame
Margin="10"
Padding="10"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
BorderColor="Blue"
CornerRadius="5"
HasShadow="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="sample" />
<Label Grid.Row="1" Text="sample2" />
</Grid>
</Frame>
<ContentView AbsoluteLayout.LayoutBounds="1, 0, -1, -1"
AbsoluteLayout.LayoutFlags="PositionProportional">
<Image Source="myIcon.png" />
</ContentView>
</AbsoluteLayout>
有什么建议吗?
答案 0 :(得分:0)
为图标指定特定的宽度和高度,并将Frame的边距设置为比例值。您可以更改Frame的边距值以使其适合您的需要:
<AbsoluteLayout>
<Frame
Margin="10"
Padding="10"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
BorderColor="Blue"
CornerRadius="5"
HasShadow="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="sample" />
<Label Grid.Row="1" Text="sample2" />
</Grid>
</Frame>
<Image AbsoluteLayout.LayoutBounds="1, 0, 25, 25"
AbsoluteLayout.LayoutFlags="PositionProportional"
Source="myIcon.png" Aspect="AspectFit" />
</AbsoluteLayout>