0

enter image description here

I have implemented sticky headers with RecyclerView. Now I want to add one textview and one imageview above RecyclerView while scrolling sticky headers is working fine and textview should be scrolled above and its should not visible.

Jon
  • 9,156
  • 9
  • 56
  • 73
  • 1
    Possible duplicate of [How can I make sticky headers in RecyclerView?](https://stackoverflow.com/questions/32949971/how-can-i-make-sticky-headers-in-recyclerview-without-external-lib) – Vishal Yadav Aug 18 '17 at 12:37
  • Your question is not clear. You've implemented a sticky header already or not? If this is the question is about how to add a sticky header in a `RecyclerView` then its a duplicate question and you should delete the question as there are several answers you'll find here in StackOverflow. – Reaz Murshed Aug 18 '17 at 12:49
  • @Reaz Murshed I have implemented sticky header recylerview above to that i have one textview and imageview only sticky header should stay in the top but now textview and imageview statying in the top of the page as you see in screenshots – Dhinakar Munirathinam Aug 18 '17 at 12:57
  • Can you please see this answer? That might help I guess. https://stackoverflow.com/questions/26448717/android-5-0-add-header-footer-to-a-recyclerview/31154402#31154402 – Reaz Murshed Aug 18 '17 at 13:13
  • Reaz Murshed : While scrolling the imageview and textview should be scrolled up and sticky header only should be stayed in the top but now both textview and header is staying in the top..... – Dhinakar Munirathinam Aug 18 '17 at 13:31

1 Answers1

0
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        if (viewType == TYPE_ITEM) {
            //Inflating recycle view item layout
            View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.headerview, parent, false);
            return new ItemViewHolder(itemView);
        } else if (viewType == TYPE_HEADER) {
            //Inflating header view
            View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
            return new HeaderViewHolder(itemView);
        } else return null;


    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {


        if (holder instanceof HeaderViewHolder) {
            HeaderViewHolder headerHolder = (HeaderViewHolder) holder;



        } else if (holder instanceof ItemViewHolder) {

            ItemViewHolder itemholder = (ItemViewHolder) holder;
            }
    }

    @Override
    public int getItemCount() {

        return contactVOList.size();
    }

    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return TYPE_HEADER;
        }
        return TYPE_ITEM;
    }

    private class HeaderViewHolder extends RecyclerView.ViewHolder {



        public HeaderViewHolder(View view) {
            super(view);


            layout = (RelativeLayout) view.findViewById(R.id.layout);

        }
    }

    private class ItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

        TextView name;
        ImageView icon;

        public ItemViewHolder(View itemView) {
            super(itemView);
            itemView.setOnClickListener(this);
            name = (TextView) itemView.findViewById(R.id.name);
            icon = (ImageView) itemView.findViewById(R.id.icon);

        }

        @Override
        public void onClick(View v) {

            Context context = itemView.getContext();
            int position = getAdapterPosition();

        }
    }

}
Aman Verma
  • 3,155
  • 7
  • 30
  • 60