简体   繁体   English

Xamarin形式:图像未显示为完整的圆圈

[英]Xamarin forms: Image is not showing in perfect circle

I already posted a question regarding this issue, never get any solution. 我已经发布了有关此问题的问题,但从未得到任何解决方案。 So posting the same question with more details and findings. 因此,发布具有更多详细信息和发现的相同问题。

For the circle images, I am using Xam.Plugins.Forms.ImageCircle nuget package in my project, which is working fine in android and windows but showing an oval shape in IOS, screenshot adding below. 对于圆形图像,我在项目中使用Xam.Plugins.Forms.ImageCircle nuget程序包,该程序在android和windows上运行良好,但在IOS中显示为椭圆形,下面添加了屏幕截图。

在此处输入图片说明

Added ImageCircleRenderer.Init(); 添加了ImageCircleRenderer.Init(); in AppDelegate.cs. 在AppDelegate.cs中。

xmlns namespace added: xmlns名称空间已添加:

xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"  

  <controls:CircleImage 
          HorizontalOptions="Start"
          VerticalOptions="Start"
          Margin="0,0,0,-5"
          WidthRequest="50" 
          Aspect="AspectFill"
          BorderColor="#1C7DB4"
          BorderThickness="2"
           HeightRequest="50" />

Now I updated the Xam.Plugins.Forms.ImageCircle to 2.0.2 and the resulted image is adding below: 现在,我将Xam.Plugins.Forms.ImageCircle更新为2.0.2,结果图像添加如下:

在此处输入图片说明

Thanks in advance 提前致谢

It looks as if you are displaying the circles in a ListView , which has a fixed height of the cells per default. 看起来好像是在ListView中显示圆圈,默认情况下,它具有固定高度的单元格。 It seems as if your cells are simply not high enough to give the CircleImage s the space they need. 似乎您的单元格不够高,无法为CircleImage提供CircleImage的空间。 You have two options to overcome this: 您有两种选择可以解决此问题:

  • Set the cells heigth to a fixed value that is high enough. 将单元格高度设置为足够高的固定值。
    • I don't know the exact value of the cells padding, so you'll have to experiment a bit. 我不知道单元格填充的确切值,因此您必须进行一些实验。 Maybe start off with something around 60 也许从60左右开始

<ListView RowHeight="60" ...>

  • Set HasUnevenRows="true" 设置HasUnevenRows="true"
    • I believe that this will fix the rows height automagically, but it comes at costs: There may be a negative impact on layouting your view. 我相信这将自动确定行的高度,但这是有代价的:可能会对视图的布局产生负面影响。

<ListView HasUnevenRows="true">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM