Code example for AbsListView

Methods: getChildAt

0
                        // The first item is not shown, the header should be pinned at the top. 
                        mHeader.setOffset(mHeader.getMaximumScrollableHeaderOffset()); 
                        return; 
                    } 
 
                    View firstVisibleItemView = view.getChildAt(firstVisibleItem); 
                    if (firstVisibleItemView == null) { 
                        return; 
                    } 
                    // We scroll the header up, but at most pin it to the top of the screen. 
                    int offset = Math.min( 
                            (int) -view.getChildAt(firstVisibleItem).getY(), 
                            mHeader.getMaximumScrollableHeaderOffset()); 
                    mHeader.setOffset(offset); 
                } 
 
                @Override 
                public void onScrollStateChanged(AbsListView view, int scrollState) { 
                    // Nothing to do here. 
                } 
            };