Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand CardView inside RecyclerView as New Activity like Inbox by Google Android

I'm Using Recycler View as my listview and CardView as list item. I want to expand the Cardview when I click on any item of the list like it expands in inbox app by Google/Gmail. Please guide!

like image 868
Zeeshan Ahmed Avatar asked Apr 09 '15 07:04

Zeeshan Ahmed


1 Answers

Trick: You can change one of your item's height (inside your CardView) in your adapter. For example i have TextView in my CardView, when CardView item is clicked, i change height of TextView to 300:

public class courseListAdapter extends ListAdapter<courseListAdapter.ViewHolder> {
....
public class ViewHolder extends RecyclerView.ViewHolder implements
                View.OnClickListener,View.OnLongClickListener{
    TextView courseCRN;      
    ....
    public ViewHolder(View itemView, ClickListener listener)  {
        super(itemView);
        courseCRN = (TextView) itemView.findViewById(R.id.course_crn);

    }
    @Override
    public void onClick(View v) {   

                    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, 300, 1f);
                    courseCRN.setLayoutParams(lp);


     }
}

Initial:

enter image description here

Later:

enter image description here

like image 127
Jemshit Iskenderov Avatar answered Sep 30 '22 23:09

Jemshit Iskenderov