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!
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:

Later:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With