Expanding/Collapsing CardView with click or swipe gesture (Android)? -
i'm looking solution allow me expand cardview see more information , collapse it. google keep has examples of cards this. know how this? create 2 versions of cardview (one collapsed , 1 expanded) , use animator class coupled gesture methods transition between 2 views? i'm using recyclerview hold cardviews.
i found if @ relevant: http://developer.android.com/training/animation/layout.html
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.cardview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <linearlayout android:layout_width="match_parent" android:orientation="vertical" android:animatelayoutchanges="true" android:layout_height="match_parent"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content"> //here put view visible <linearlayout android:layout_width="match_parent" android:visibilty="gone" android:id="@+id/expandablelayout" android:layout_height="wrap_content"> //here put collapse , expand </linearlayout> </android.support.v7.widget.cardview>
take boolean isexpanded in arraylist object class
if (listobj.isexpanded) { holder.expandablelayout.setvisibility(view.visible); } else { holder.expandablelayout.setvisibility(view.gone); } holder.cardview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if (listobj.isexpanded) { holder.expandablelayout.setvisibility(view.gone); listobj.isexpanded=false; notifyitemchanged(position); } else { holder.expandablelayout.setvisibility(view.visible); listobj.isexpanded=true; notifyitemchanged(position); } } });
try someting this
Comments
Post a Comment