Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

header view should be invisible for top item (when the pinned header goes from an invisible to visible state) #7

Open
cliffsun91 opened this issue May 19, 2015 · 8 comments

Comments

@cliffsun91
Copy link

Hi, great little library btw, we've had some issues with the default android listviews and different height cells (some cells are header sections) with, which has caused bugs on some devices when using fastscroll (with certain datasets in the list). Your little POC library is great because its fits in with the new android design and also works great as all the cells are the same heights.

I've been trying to integrate your code into an application I am working on, however I noticed that there are a few small tweaks that are needed. The main one being that if you were to set the backgroundColor of the header views to transparent/null (comment out
'mAdapter.setPinnedHeaderBackgroundColor(pinnedHeaderBackgroundColor);' in MainActivity), you'll notice that when you scroll up so that the first item of an alphabetical section becomes 'pinned' (i.e. the pinned header view becomes visible in that locked position on the screen), you'll see the header view for the cell behind it still. Your sample app doesn't show this normally as you explicitly set the background colour for the header views, however if you have an app with a common background (which has a gradient for example), you'd want to allow the background of the header view to be transparent.

I suspect that all we would need to do is in PinnedHeaderListView.configureHeaderView(int position) in the PINNED_HEADER_VISIBLE state is find the first visible element of the list and make the header view in that invisible. Oppositely when the pinned header goes into the PINNED_HEADER_GONE state (which seems to only happen when scrolling up between the beginning of a section and the end of the previous section) we should then find the first visible element of the list and make the header view visible.

@AndroidDeveloperLB
Copy link
Owner

Not sure I understand. Can you please show a gif animation of the issue?
Also, this POC was made a long time ago, so I'm not sure how much I can be of assistance . :(

@cliffsun91
Copy link
Author

screenshot_2015-05-19-13-04-57
screenshot_2015-05-19-13-05-09

So i set the backgrounds for the header views (the A's) to null, i.e. transparent. You can see when I scroll up and the pinned header is anchored the header view attached to the list item itself is still visible. It wasn't visible originally as the background was set to an explicit colour (thereby hiding it).

I understand if you won't be able to do anything about it, I saw your last commit was a while ago. I like the library though, its small and simple and works quite well (and I haven't found anything else that isn't overly complicated like this). I can fix it myself but if I don't know if you'll be willing to take a pull request in the future at some point.

@AndroidDeveloperLB
Copy link
Owner

Using my sample, I can't reproduce the bahavior you are showing on the image.
The headers aren't supposed to be duplicated this way.
The code is written in a way that hides the header when needed. Also it hides the fact that the rows include the left area.
I don't know what you change that caused it.

@cliffsun91
Copy link
Author

you don't have any code anywhere sets the header that is part of the row invisible (not the pinned/sticky one). I added some code to the PINNED_HEADER_VISIBLE and PINNED_HEADER_PUSHED_UP switch statements in configureHeaderView which finds the top (first visible) item/row in the ListView and sets the header TextView to invisible. I can't quite remember why we had to add the code to both switch statements, but I recall that the pinned header state that was returned wasn't very consistent with what was happening on screen.

You definitely commented out:

mAdapter.setPinnedHeaderBackgroundColor(pinnedHeaderBackgroundColor);

in MainActivity?

If you don't set a backgroundColor then the background is transparent and you should see the header TextView (which is part of the row) behind it.

@AndroidDeveloperLB
Copy link
Owner

Sorry, this was a long time ago so I don't remember exactly what I did, but I still can't reproduce what you've shown.

@AndroidDeveloperLB
Copy link
Owner

Does the sample work fine for you though?

@praveen2gemini
Copy link

@cliffsun91 I'm also getting this issue. But Applying same color code for Header view and List single item view we can hide the issue. This is not a standard solution. But It works.

@Verdurakh
Copy link

Maybe a little Necro but I had the same problem and it was solved by making sure that the color selected for the background has no alpha in it. for example setting it to Color.WHITE solved it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants