@jmpessoa --> Feature request !
I would like to ask you for the possibility to add a canvas to ListView.
At the moment, I am doing this (on a long viewlist):
@Override
public void onDraw
( Canvas canvas
) { super.onDraw(canvas);
View c
= super.
getChildAt(0); int scrollposition = -c.getTop() + super.getFirstVisiblePosition() * (c.getHeight()+super.getDividerHeight());
myPaint.
setColor(Color.
rgb(200,
0,
0)); myPaint.setStrokeWidth(25);
canvas.drawRect(100, 800 - scrollposition, 200, 900 - scrollposition, myPaint);
}
@Override
protected void dispatchDraw
(Canvas canvas
) { super.dispatchDraw(canvas);
View c
= super.
getChildAt(0); int scrollposition = -c.getTop() + super.getFirstVisiblePosition() * (c.getHeight()+super.getDividerHeight());
myPaint.
setColor(Color.
rgb(0,
200,
0)); myPaint.setStrokeWidth(25);
canvas.drawRect(100, 2000 - scrollposition, 400, 2200-scrollposition, myPaint);
}
The former draws a square behind the ListView.
The latter draws a square before the ListView.
Both move along with scrolling, due to the scrollposition.
I would like to do this in an OnDraw and an OnDispatch of the listview (drawing on the attached Canvas).
These two will also have to transport the scroll-position !
Is this possible ?
Thanks.