Android imitation Taobao logistics tracking example code

Today, I'd like to talk about the logistics tracking effect in my mind. The effect picture is as follows. Friends in need can take it away directly. The implementation is not as complex as expected, especially the time axis on the left

@H_ 419_ 4@

To get this picture, the first thing we think of is that this is a RecyclerView to achieve. What may be more puzzling is the red dot and gray dot, and the vertical line between the dots. The most important thing is that the height of the vertical line is adaptive, not fixed height, and the old fellow said, "did you notice the pain in your mouth?" If you can solve the problem of this time axis, you can also say that I can go on.

After reading the online, some people say that they want a custom view, which is both drawing and measurement. In fact, it is not so complicated. Let's talk about how I solve it. After thinking about it, it can be realized by the relative position of each view. For example, the dot can also be realized by ImageView. The only difference is that the vertical line view passes through the gray circle view. Have you found that except for the first dot, other dots are on the left side of the fixed height position under the horizontal division line (I seem to be 10dp here), Then I can get an empty view under the split line. Then the vertical line passing through the circular hole is above the empty view, below the dot, and the height is match. In this way, through a relative layout, the problem of the timeline is also solved

item_ trace

MainActivity

Adapter

GitHub address (welcome to download the full demo): https://github.com/zhouxu88/LogisticsDemo

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
分享
二维码
< <上一篇
下一篇>>