Android arc ListView implementation, androidlistview
This article will show you how to arrange the Arc Distribution of ListView. The principle is very simple, that is, to offset each Item based on the height of each item in ListView.
First, define a LinearLayout. This is the root layout of each Item in ListView, which is used to offset each item.
The code below:
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"> // input the height of ListView h = height ;} @ 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 (widthMeasureSpec, 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 ;}}
Next, you can write a demo and test it by yourself. You can write a ListView and use the custom MatrixLinearLayout above as the root layout of the ListView item!
How does android listview achieve this rounded corner and press effect? The question is sent again. Come and get the score.
It can be done by layout and a little logic. Specifically, the list body actually has a Margin value left and right, while the above transparent cover layer is full between the left and right, which makes it easy.
You can see the demo of my attachment. I have not adjusted the color. I am not very good at Color adjustment. But the effect is similar.
How does android use CheckBox + ListView to obtain the values of multiple controls on the selected items!
The score is too low !!!