In fact, the bookshelf works well. You only need to calculate the location rectangle of the bookshelf in the ondraw () method of the custom gridview, and then the draw will be OK. I personally think it is relatively simple.
The Code is as follows:
Public class playbackfocusedgridview extends focusedgridview {
Drawable minterlayer = This. getresources (). getdrawable (R. drawable. TV _playback_shelf); // bookshelf Image
Rect mmydrawrect = new rect (); // rectangular position of the bookshelf
Public playbackfocusedgridview (context contxt, attributeset attrs, int defstyle ){
Super (contxt, attrs, defstyle );
}
Public playbackfocusedgridview (context contxt, attributeset attrs ){
Super (contxt, attrs );
}
Public playbackfocusedgridview (context contxt ){
Super (contxt );
}
@ Override
Protected void ondraw (canvas ){
Int COUNT = getchildcount ();
If (count> 0) {// when there is content
View v = getchildat (0); // obtain the first visible view on the screen
If (V! = NULL ){
Int gridview_height = This. getheight ();
Int interlayerheight = minterlayer. getintrinsicheight ();
Int blockgapheight = V. getheight ();
Mmydrawrect. Left = 0;
Mmydrawrect. Right = getwidth ();
Int initpos = V. gettop ();
For (INT I = initpos; I <= gridview_height; I ++ = blockgapheight ){
Mmydrawrect. Top = I;
Mmydrawrect. Bottom = mmydrawrect. Top + interlayerheight;
Minterlayer. setbounds (mmydrawrect );
Minterlayer. Draw (canvas); // draw a gallery Image
}
}
Super. ondraw (canvas); // draw each item
}
}
}