Alan_Xu Alan_Xu - 4 months ago 27
Android Question

How to dynamically add slices to a disk image?

Hi I am new to Android and I am currently experimenting with some Android features.
So I wanted to find a way to add flexibly add slices to a disk image (could be a pie chart or a roulette wheel). I have done some research on this topic, Drawable Resources | Android. If I wanted to insert a slice dynamically, I think the

method would best suit my situation. So that a bitmap would not be recreated every time the image changes. I have also gone over some tutorial on how to change Cartesian coordinates into Polar coordinates Android SDK: Creating a Rotating Dialer. I was hoping to combine the
method with the polar coordinates to achieve this function. So I was wondering if can anyone tell me whether or not my thoughts are feasible?

A sample of the image that I would like to get is shown below:


Instead of having 6 slices, the user could add more elements to populate the disk to make it 8 or 10 slices, or remove slices from the disk.

It would be great if anyone can share a link to some of the related topics or tutorials as such.

Thanks in advance :)


What is that you exactly want? If you want to dynamically add a slice every time you click a button, all you have to do is arrange the 6 slices in the form of a circle in the xml as 6 ImageViews. You will have to make these ImageViews invisible initially. And inside the onClick function of the button you make the ImageViews visible one by one.