带圆圈的标签Xamarin形式 [英] Circled Label Xamarin Forms

查看:118
本文介绍了带圆圈的标签Xamarin形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的屏幕截图中看到,有一个带有孔号的标签,我想在该标签周围创建一个圆圈,我将如何实现这一目标?

A seen in the below screenshot there is a label with a hole number, I want to create a circle around this label,how would I go about achieving this?

现在我的假设是要实现这一点,我将需要创建一个自定义渲染器并覆盖Label类,但是从那里我不确定如何绘制圆并达到预期的结果.

Now my assumption is that to achieve this I will need to create a custom renderer and override the Label class but from there I'm not sure how I would draw the circle and achieve the expected results.

任何指导和协助将不胜感激.

Any guidance and assistance would be greatly appreciated.

推荐答案

在以下链接上,您将找到 RoundedBoxView 的代码和视频(在页面的下半部分).

On the following link you will find the code and video for a RoundedBoxView (half way down the page).

http://forums.xamarin.com/discussion/17792/video-on-make-custom-renderers

如果在项目中创建此标签,则可以执行以下操作来创建四舍五入的框标签:-

If you create this within your project you can then do the following to create your rounded box label:-

*)网格作为外部控件.

*)创建一个 RoundedBoxView 作为网格以创建您的圈子-您可以在网格外部控件可以知道要指定 RoundedBoxView CornerRadius 属性的值,或者也可以挂钩到 SizeChanged 事件处理程序中以设置值.

*) Create a RoundedBoxView as a child of the Grid to create your circle - You could either specify fixed width/height on the grid outer control to know what value to specify the RoundedBoxView's CornerRadius property, or alternatively hook into the SizeChanged event handler to set the values.

*)还将 Label 控件创建为 Grid 控件的子级,并将其位置居中.

*) Create a Label control also as a child of the Grid control, and center the position of it.

然后,您可以在水平 StackLayout 中的标签中创建文本,然后添加以上内容创造出您想要的效果.

You can then create your Hole text in a Label within a horizontal StackLayout and then add the above in to create the effect you desire.

这篇关于带圆圈的标签Xamarin形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆