Android implements multiple continuous digital circle effects

There are project requirements to draw multiple circles and arrange them with consecutive numbers, that is, many rows of circles.

Let's first look at the renderings:

A row is set to 8, with a total of 53:

There are 153 in a row with 5 values:

The size of the circle can be automatically adjusted according to the total number and the number of rows, and different click effects can be made according to the incoming listening events.

The idea is very simple. First, draw a circle:

Then create a textview and set the background of the textview to this drawable.

You can calculate the appropriate size of each circle according to the total width of the screen and the number of circles to be placed in each row, and then set the margin between each circle to one tenth of the circle, so the final size of the circle should be eight tenths of the average value.

Then use the LinearLayout layout to dynamically load multiple textviews, and set the corresponding properties for each textview.

Because there may be too many circles, you need to nest Scrollview to support sliding events. Note that there can only be one child node under Scrollview.

Full code:

You can use it directly in the activity:

Code structure:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>