Android customized ViewGroup to realize the like layout of stacked avatars
brief introduction
How about such a likes list? In the past, there were similar praise lists in the community, but there was no such overlap. A small change forced me to improve a lot.
This is very regular, that is, the latter avatar will cover part of the previous avatar, and more avatars are like a string of sugar gourd.
This is not difficult to implement. Customize the ViewGroup and override the onlayout method.
For the basic knowledge of custom controls, you can take a look at this, which is sorted in detail: https://github.com/GcsSloop/AndroidNote
realization
Custom properties
In the onmeasure method, the width of each row is no longer the sum of the width of the child, but the sum of the width of the overlapping part is subtracted
Onlayout for each row, the first row is normally placed, and the next row is overlapped
design sketch
Because only one row will be displayed, the data source is not set through setadapter for the time being.
download
https://github.com/LineChen/PileLayout
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.