简体   繁体   English

使用 arc Android 创建比萨饼的形状

[英]Creating shape of pizza using arc Android

I am relatively new to canvas .我对 canvas 比较陌生。 I want to achieve this kind of view using canvas in android .我想在 android 中使用 canvas 来实现这种视图。 I have tried 2 approaches我尝试了 2 种方法

1.) Created a custom view class and called that view from xml 6 times changing angles. 1.) 创建一个自定义视图类并从 xml 6 次改变角度调用该视图。 All these custom views were overlapping and provieded with margins to create the look.所有这些自定义视图都是重叠的,并提供了边距来创建外观。

2.) Created a view class with all 6 arcs placed next to each other. 2.) 创建了一个视图类,其中所有 6 条弧线并排放置。 In this approach, I am not able to provide margin between 2 pieces.在这种方法中,我无法提供 2 件之间的余量。

Moreover , how to write text on individual piece.此外,如何在单个作品上写文字。 If I use drawTextOnPath, text is written but the angle of text is obviously in accordance to the path.如果我使用drawTextOnPath,则写入文本但文本的角度显然与路径一致。 How to write horizontal text as shown in picture?如何写出如图所示的水平文字?

Any kind of guidance will be appreciated任何形式的指导将不胜感激

在此处输入图片说明

It would be easier to use third party libraries in this case, because simple drawing "pie view" requires a lot of implementation.在这种情况下使用第三方库会更容易,因为简单的绘制“饼图”需要大量的实现。 See for example this lib .参见例如这个lib

This library has a lot of useful controls, not only pie chart.这个库有很多有用的控件,不仅仅是饼图。

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

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