带圆圈的标签 Xamarin 表单 [英] Circled Label Xamarin Forms

查看:28
本文介绍了带圆圈的标签 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/视频制作自定义渲染器

如果您在项目中创建此标签,则可以执行以下操作来创建圆框标签:-

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

*) Grid 作为外部控件.

*) Grid as the outer control.

*) 创建一个 RoundedBoxView 作为 Gridchild 来创建您的圆 - 您可以在网格外部控件知道要指定RoundedBoxViewCornerRadius 属性的值,或者挂钩到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天全站免登陆