我有以下代码:
<ScrollView Orientation="Vertical" Padding="0" VerticalOptions="FillAndExpand">
<StackLayout Spacing="0" Padding="15,0">
<Frame HasShadow="false" BackgroundColor="Transparent" Padding="0">
<RelativeLayout BackgroundColor="Olive" Padding="0" VerticalOptions="End">
<Frame HeightRequest="100" WidthRequest="100" BackgroundColor="Purple" Padding="0" HasShadow="false">
<Image HeightRequest="50" WidthRequest="50" Source="assets/avatar-man.png"></Image>
</Frame>
<BoxView HeightRequest="100" BackgroundColor="Teal" RelativeLayout.XConstraint="{ConstraintExpression Type=Constant, Constant=100}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-100}" />
<Frame BackgroundColor="Transparent" HasShadow="false" Padding="0" RelativeLayout.XConstraint="{ConstraintExpression Type=Constant, Constant=100}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-100}">
<Label>Hello</Label>
</Frame>
</RelativeLayout>
</Frame>
</StackLayout>
</ScrollView>
但是,由于某种原因,图像高度请求被忽略,它没有显示 50x50 单位正方形,而是像这样填满整个屏幕:
有谁知道为什么这会被忽略以及如何解决这个问题?
最佳答案
我遇到了同样的问题,我最终像这样在我的图像周围包装了一个 StackLayout:
<StackLayout>
<Image Source="{Binding MyImage}" WidthRequest="50" HeightRequest="50"/>
</StackLayout>
关于c# - Xamarin 表格 : Image height request ignored inside frame inside relative layout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30427009/