如何画线的Andr​​oid圈子圈子、画线、Andr、oid

2023-09-09 21:00:14 作者:〃阎王

我想有其特点是列圆的,与他们在纯色背景similiar一到这个(指圈排在底部)的可绘制资源。我想表现它左去右,并具有可绘制资源是实现它的第一个步骤的动画。我怎样才能做到这一点。谢谢

I wanted to have a drawable resource that features a row of circles, with one of them in solid background similiar to this (refer to the row of circles at the bottom). I wanted to show an animation of it going from left to right, and having a drawable resource is the first step of achieving it. How can I do that. thanks

推荐答案

我用一个TextView到五根弦(我有5个步骤)所有由具有统一code字符(\ u26​​cb为空圆)和( \ u26​​cf为实心圆)。

I use a TextView to which five strings (I have 5 steps) all composed with Unicode characters (\u26cb for the empty circle) and (\u26cf for the filled circle).

这样的(我保存他们在我的 RES /价值/ arrays.xml 文件):

Like this (i stored them in my res/values/arrays.xml file):

<!-- Steps -->
<string-array name="steps">
    <item>\u25cf \u25cb \u25cb \u25cb \u25cb</item>
    <item>\u25cb \u25cf \u25cb \u25cb \u25cb</item>
    <item>\u25cb \u25cb \u25cf \u25cb \u25cb</item>
    <item>\u25cb \u25cb \u25cb \u25cf \u25cb</item>
    <item>\u25cb \u25cb \u25cb \u25cb \u25cf</item>
</string-array>

所以,当阵列被加载时,我可以很容易地设置TextView的文本在当前步骤基础。

So, when the array is loaded, I can set the TextView's text easily basing upon the current step.

正如你可能知道,统一code字AR不仅是人物......你可以有一些图形图标(象形文字)。 这其中,你会发现圆(填入空)。

As you probably know, Unicode characters ar not only "characters"... you can have some graphic icons (glyphs). Among these, you find circles (filled and empty).

在数组中的第一行绘制一个实心圆其次是4空圈。 第二行绘制了一个空的圆圈,实心圆和3空圈,等等。

The first line in the array DRAWS a filled circle followed by 4 empty circles. The second line DRAWS an empty circle, a filled circle and 3 empty circles, and so on.

要动画行,只是通过你的TextView的下一个元素的数组中开始。作为其文本。

To "animate" the row, just pass your TextView the next element in the array. as its text.

下面是在这个过程中呈现出的5 第2步的模拟LDPI设备的屏幕。 这是第二个数组元素

Here's an emulated ldpi device screen showing step 2 of 5 in the process. This is the second array element.

在屏幕的底部

为什么我选择,而不是图片文字? 因为它是: 光(一TTF字体是矢量图形), 可扩展(我没有提供几种PNG图像为不同的屏幕分辨率), 轻松(读取数组一次,并据此设置一个TextView的文字), 维护(我应该添加或删除一些步骤,它的相应修改字符串数组只是一个问题)

Why did I choose text instead of images? Because it is: light (a ttf font is vectorial graphics), scalable (I don't have to provide several PNGs for different screen resolutions), easy (read the array once, and set a TextView's text accordingly), maintainable (should I add or remove some steps, it's just a matter of modifying the string array accordingly)