简体   繁体   中英

How to display fully visible Items in top of the Listview after scrolling?

how to proceed forward in the listview . i am having listitem consists of 30 items which displaying only images .

In visible screen we can able to see minimum 1 1/2 images per screen(ie., one full image and half of the second Image).. When I scrolling the listview , many times it happen top item in the listview is partially visible(ie, only half can be seen). So i want restrict that in the listview ...After Scrolling i want display only fully visible items in top of the Listview , avoiding partially visible items in top of the listview .

Can anyone help me. Please suggest any ides to solve this issues.

mListView.setOnScrollListener(new OnScrollListener() {
    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
        if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
            mListView.smoothScrollToPosition(mListView.getFirstVisiblePosition());
        }
    }
    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    }
});

Finally i am got it based on setSelection() method.

mainListView.setOnScrollListener(new OnScrollListener() {
        //int currentTopVisible;
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            int index=mainListView.getFirstVisiblePosition();
            mainListView.setSelection(index);

} }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {

        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM