I make small project with RecyclerView with CardView items inside. I created expandable card (expanded by pressing on small button inside the card). Each card always contain
What tecnique are you using in order to do that?
I was in the same situation but for me the problem were these functions ExpandAndCollapseViewUtil.expand() and ExpandAndCollapseViewUtil.collapse() from this tutorial Diseño Android: Tarjetas con CardView so I didn't use it. Instead of that I just show/hide the view of the cardview without any animation.
You can use this lib instance your self developed way, try this:
STEP 1: Add below dependency to your build.gradle
file:
**compile 'com.github.traex.expandablelayout:library:1.2.2'** use instead of
compile 'com.github.traex.expandablelayout:library:1.3'
STEP 2: Add below View to Your card layout ,card_layout
Must be look like this:
<com.andexert.expandablelayout.library.ExpandableLayout
android:id="@+id/row_0"
xmlns:expandable="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
expandable:headerLayout="@layout/YOUR_CARD_VIEW_UI"
expandable:contentLayout="@layout/YOUR_CARD_VIEW_EXPANDED_UI"/>
STEP 3: In your define of RecyclerView remember to:
recList.setItemViewCacheSize(ITEMS_COUNT);
Feel free to Ask :-)
I had the same problem and solved it by putting following code (Kotlin) in the ViewHolder
if (expandableView.isVisible) {
val recyclerView = containerView?.parent as RecyclerView
recyclerView.adapter.notifyItemChanged(adapterPosition)
recyclerView.smoothScrollToPosition(adapterPosition)
}
As you see before scroll to a position I notified the adapter that the item on this position was changed. And I only do this if the view became visible