This article takes you to realize the circular distribution of the ListView, the principle is very simple, that is, according to the ListView each item's height to offset each item.
First, customize a linearlayout, which is the root layout of each item in the ListView, which is used to offset each item.
The following code:
public class Matrixlinearlayout extends LinearLayout {private int h = 0; private float Fulltrans = 40f; Public MatrixView (context context, AttributeSet Attrs) {Super (context, attrs); } public void Setparentheight (int height) {<pre name= "code" class= "Java" >//Incoming ListView height H = heigh T } @Override protected void Dispatchdraw (canvas canvas) {canvas.save (); int top = GETTOP (); Float trans = Calculatetrans (top,h); Matrix m = Canvas.getmatrix (); M.pretranslate ( -2/getwidth (), -2/getheight ()); M.posttranslate (trans, 0); Canvas.concat (m); Super.dispatchdraw (canvas); Canvas.restore (); } @Override protected void onmeasure (int widthmeasurespec, int heightmeasurespec) {super.onmeasure (widthmeas Urespec, Heightmeasurespec); } private float Calculatetrans (int top,int h) {float result = 0f; if (top <= h/2.349f) {result = (H/2f-top)/(h/7f) *fulltrans; }else if (Top > h/2.349f) {result = (top-h/3f)/(h/7f) *fulltrans; } return result; }}
Below you can write your own demo test, is to write a ListView, and then use the above custom Matrixlinearlayout as the ListView item's root layout, self-clothed!