ios - 无法更改 MapView [Xamarin] 的大小
问题描述
我的自定义 ViewRenderer 中有一个 MapView。我正在尝试像这样设置它的大小:
public CustomMapRenderer()
{
var camera = CameraPosition.FromCamera(47.497913, 19.040236, 15);
mapView = new MapView(new CGRect(0, 0, 414, 200), camera); //also tried with this: mapView = MapView.FromCamera(new CGRect(0, 0, 414, 200), camera);
this.AddSubview(mapView);
...
}
如果我在调试器中检查它,该视图似乎仍处于全屏状态(414 * 896)。由于我发现的文档不多,所以我问我是否正确设置它?如果是这样,那是一个错误吗?我应该如何更改视图的大小?
编辑:也添加了相关的 XAML 代码
嵌入地图的 XAML 是:
<?xml version="1.0" encoding="UTF-8"?>
<attractionbase:AttractionContentListItemBase xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:attractionbase="clr-namespace:AppTourism.CardView.ItemTypes.AttractionPage"
xmlns:map="clr-namespace:AppTourism.MapModule"
mc:Ignorable="d"
x:Class="AppTourism.CardView.ItemTypes.AttractionPage.AddressWithMapContentListItem">
<Frame
HasShadow="False"
Padding="0"
Margin="{Binding MainFrameMargin}"
RelativeLayout.XConstraint="{ConstraintExpression Type=Constant,Property=X,Constant=0}"
RelativeLayout.YConstraint="{ConstraintExpression Type=Constant,Property=Y,Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width}">
<StackLayout Orientation="Vertical" Spacing="0" Margin="0" >
<StackLayout Orientation="Vertical" Margin="10" >
<StackLayout Orientation="Horizontal">
<Image Source="iMarkerSmall.png" HeightRequest="30"></Image>
<Label Text="{Binding Pin.Address}" FontSize="Medium" TextColor="Black"></Label>
</StackLayout>
<Frame Padding="0" HeightRequest="100" CornerRadius="20" HasShadow="False">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="Map_Tapped"></TapGestureRecognizer>
</Frame.GestureRecognizers>
<AbsoluteLayout>
<map:CustomMap x:Name="Map" IsEnabled="False"
AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" />
<Label Text="N/A" FontSize="Medium" FontAttributes="Bold" TextColor="Black" Margin="5,0" VerticalOptions="Center" x:Name="NALabel" IsVisible="False"
AbsoluteLayout.LayoutBounds="0.5,0.5,AutoSize,AutoSize" AbsoluteLayout.LayoutFlags="PositionProportional" ></Label>
</AbsoluteLayout>
</Frame>
</StackLayout>
<BoxView HeightRequest="{Binding SEPARATOR_HEIGHT}" Margin="{Binding SeparatorMargin}">
<BoxView.BackgroundColor>
<Color>#e6e6e6</Color>
</BoxView.BackgroundColor>
</BoxView>
</StackLayout>
</Frame>
</attractionbase:AttractionContentListItemBase>
解决方案
推荐阅读
- assembly - 装配过程中的顺序
- python - 是否可以删除python中字节的最后一个字节?
- python - 由另一列中的数值引导的列中的完整字符串值
- python - 将python浮点数转换为字节
- laravel - 删除请求重定向到未找到
- ios - 如何在 iOS Objective-C 中集成“使用 Apple 登录”流程?
- javascript - 如何使用 c3js 显示条形图的标签?
- java - Java流在reduce操作的情况下给出语法错误
- serialization - Json.NET - 有条件地序列化
- c# - 在 C# 中使用 ExcelLibrary 创建具有多个工作表的多个 excel