Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Only last header is visible #165

Open
graisVictory opened this issue Feb 4, 2019 · 3 comments
Open

Only last header is visible #165

graisVictory opened this issue Feb 4, 2019 · 3 comments

Comments

@graisVictory
Copy link

graisVictory commented Feb 4, 2019

The issue reproduces periodically without any rules.
onCreateHeaderViewHolder and onBindHeaderViewHolder gets called, but headers are not visible
My code looks like

override fun getHeaderId(position: Int): Long {
    return clients[position].companyName.toUpperCase().get(0).toLong()
}
override fun onCreateHeaderViewHolder(parent: ViewGroup): HeaderHolder {
    val view = LayoutInflater.from(parent.context).inflate(R.layout.item_client_list_header, parent, false)
     return HeaderHolder(view)
}
override fun onBindHeaderViewHolder(holder: HeaderHolder, position: Int) {
    val letter = clients[position].companyName.get(0).toUpperCase().toString()
    holder.bind(letter)
}

and xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/SansMediumBig"
    tools:text="A"
    android:layout_width="match_parent"
    android:padding="@dimen/padding_small"
    android:background="@color/transparent_grey_3"/>

But no matter what font or any other style (even without any style) I'm using - result is the same.
Note that I'm using this recycle view https://github.com/myinnos/AlphabetIndex-Fast-Scroll-RecyclerView
Help me please :(

@maroney-tm
Copy link

maroney-tm commented Mar 22, 2019

It's a bit late but I was getting all sorts of weird behavior when the my recyclerview was set to android:layout_height="wrap_content". All the issues went away when I swapped to android:layout_height="match_parent". I had my recyclerview as a child in a relative layout.

My issue was that that onCreateHeaderViewHolder and onBindHeaderViewHolder were being called but the view wasn't showing. Just an empty view, of the correct size, where it should have been. Strangely the last several stickyHeaders would show up.

@lkesteloot
Copy link

@graisVictory did you figure this out? I'm getting the same behavior: The callbacks are called but only the last header is correct. The other ones are blank and much too tall. I don't think it's related to @maroney-tm's solution because my layout_weight="1", meaning that the height shouldn't depend on content.

@lkesteloot
Copy link

Okay found the problem in my case: The list view hadn't been laid out yet, so any header on-screen initially got laid out wrong.

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

No branches or pull requests

3 participants