我正在尝试在XAML中为Xamarin表单应用构建以下布局。
这是我的代码
<AbsoluteLayout
HorizontalOptions="FillAndExpand"
HeightRequest="350">
<Frame
AbsoluteLayout.LayoutFlags="SizeProportional"
AbsoluteLayout.LayoutBounds="0,0,1,1"
BackgroundColor="White"
HasShadow="true"
CornerRadius="10"
Margin="20,25,20,25">
<StackLayout>
</StackLayout>
</Frame>
<Image
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.5,1,50,50"
Source=“icon.png”/>
</AbsoluteLayout>
它在IOS上运行良好,但在android中没有正确显示图标图像。 请看下面的截图。
请帮我解决!
答案 0 :(得分:2)
我在Android中将圆形图像覆盖在框架上时遇到了同样的问题。
答案 1 :(得分:0)
试试这个。
<AbsoluteLayout HorizontalOptions="FillAndExpand" HeightRequest="350">
<Frame AbsoluteLayout.LayoutFlags="SizeProportional" AbsoluteLayout.LayoutBounds="0.5,0.5,1,1"
BackgroundColor="White" HasShadow="true"
CornerRadius="10"
Margin="20,25,20,25">
<StackLayout>
</StackLayout>
</Frame>
<Frame AbsoluteLayout.LayoutFlags="PositionProportional" Padding="0,0,0,0"
AbsoluteLayout.LayoutBounds="0.5,1,50,50" VerticalOptions="Fill" HorizontalOptions="Fill">
<Image Margin="0,0,0,0" Aspect="AspectFill" Source="icon.png"/>
</Frame>
</AbsoluteLayout>
截图
答案 2 :(得分:0)
@ nitish-gawde的回答对我来说并不适用于图像的框架HasShadow设置为false。 然而,对我有用的解决方法是将第一帧放在另一个布局(比如StackLayout)中:
<AbsoluteLayout HorizontalOptions="FillAndExpand" HeightRequest="350">
<StackLayout
AbsoluteLayout.LayoutFlags="SizeProportional"
AbsoluteLayout.LayoutBounds="0.5,0.5,1,1">
<Frame
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
BackgroundColor="White" HasShadow="true"
CornerRadius="10"
Margin="20,25,20,25">
<StackLayout>
</StackLayout>
</Frame>
</StackLayout
<Frame HasShadow = "False"
AbsoluteLayout.LayoutFlags="PositionProportional" Padding="0,0,0,0"
AbsoluteLayout.LayoutBounds="0.5,1,50,50"
VerticalOptions="Fill" HorizontalOptions="Fill">
<Image Margin="0,0,0,0" Aspect="AspectFill" Source="icon.png"/>
</Frame>
</AbsoluteLayout>