Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8863585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:00:58+00:00 2026-06-14T16:00:58+00:00

I have a listview which is obviously scrollable. The listview contains some form questions.

  • 0

I have a listview which is obviously scrollable. The listview contains some form questions. Once the user submitts the form we put a stamp-like looking custom view on top of the listview (and prevent user from answering questions, but it doesn’t matter here).

The stamp should appear at the top of the listview (as in top of the screen) and be scrollable at the same speed as the listview, i.e. it should disappear when the listview items which were initially underneath it disappear at the top of the screen when scrolled.

Any idea how to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:01:00+00:00Added an answer on June 14, 2026 at 4:01 pm

    I found a solution. Not sure if it is too elegant, but it works so will leave it unless somebody comes up with something better.

    The view which I want to scroll together with the list is a custom view, which has to know about the list view. So I implement a setListView(ListView listView) method on it:

    private int scrollY; //1
    private Map<Integer, Integer> listViewItemHeights = new Hashtable<>();
    public void setListView(final ListView listView) {
        listView.setOnScrollListener(new OnScrollListener() {  //2
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {} //3
    
            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //4
                View c = listView.getChildAt(0);
                if (c != null) {
                    int oldScrollY = scrollY;
                    scrollY = -c.getTop();
    
                    listViewItemHeights.put(listView.getFirstVisiblePosition(), c.getHeight());
                    for (int i = 0; i < listView.getFirstVisiblePosition(); ++i) {
                        if (listViewItemHeights.get(i) != null)
                            scrollY += listViewItemHeights.get(i);
                    }
                    scrollBy(0, scrollY - oldScrollY);
                }
            }
        });
    }
    

    Comment No.1: this is a variable letting me keep track of the current scroll position.

    Comment No.2: setting a new on scroll listener to let my custom view know when the list

    Comment No.3: this does not need to be implemented in this case.

    Comment No.4: this is where magic happens. Note in the end I scroll my view by scrollY – oldScrollY, let me start with this bit first. oldScrollY is the kept scroll position, scrollY is the new one. I need to scroll by the difference between them. As for how scrollY is calculated I refer you to my answer here: Android getting exact scroll position in ListView, it is how the scroll position is calculated in list view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView which contains EMPLOYEE_NAME from a DB table EMPLOYEE. Some employees
I have a listview which I would like to fill with self created user
I have a ListView which might contains a lot of items, so it is
I have a ListView which contains custom rows. This custom row has following UI
I have a listview in which a user adds his comments on a particular
I have a ListView which contains a LinearLayout on the top of the View
I have a WinForms ListView, obviously containing ListViewItems. I'd like to be able to
I have a user control which is having a listview inside it. The SelectionChanged
I have a ListView which uses a CursorAdatper as its adapter. I would like
i have a ListView which contains objects bound from an collection. The representation of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.