Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the size of a current focused item on a RecyclerView? [closed]

I'm trying to make an horizontal list with a RecyclerView, that when I put the focus on an item, increase the size of this. I want to make this effect:

Increased item effect

Do you have any ideas to accomplish this?

like image 566
Skycorsarius Avatar asked Oct 21 '15 21:10

Skycorsarius


People also ask

How do you expand collapse items in RecyclerView?

itemView. setOnClickListener(new View. OnClickListener() { @Override public void onClick(View v) { mExpandedPosition = isExpanded ? -1:position; TransitionManager. beginDelayedTransition(recyclerView); notifyDataSetChanged(); } });


1 Answers

I'm imagining something like this:

  1. Create the horizontal RV
  2. When binding the ViewHolder, attach a FocusChangeListener to the root view of the item
  3. When the item gains focus, scale it to make it slightly bigger; when the focus is lost, revert the animation.

static class ViewHolder extends RecyclerView.ViewHolder {    public ViewHolder(View root) {     // bind views     // ...      // bind focus listener     root.setOnFocusChangeListener(new View.OnFocusChangeListener() {       @Override         public void onFocusChange(View v, boolean hasFocus) {           if (hasFocus) {             // run scale animation and make it bigger           } else {             // run scale animation and make it smaller           }         }      });   } } 
like image 97
Sebastiano Avatar answered Sep 24 '22 23:09

Sebastiano