it's been quite many hours now working on this and I can't come up with solution.
I have a LinearLayout that contains two CardViews. Each CardView contains two RelativeLayouts. One RelativeLayout that is always visible, has fixed height and is clickable. The second RelativeLayout can be expanded/collapsed. The xml structure goes like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cardview_one"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/visible_part_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="toggleCardViews">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="visible part one"/>
</RelativeLayout>
<com.github.aakira.expandablelayout.ExpandableRelativeLayout
android:id="@+id/expandable_layout_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ael_expanded="true"
app:ael_duration="500"
app:ael_interpolator="linear"
app:ael_orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="expandable part one"/>
</com.github.aakira.expandablelayout.ExpandableRelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/cardview_two"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/visible_part_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="toggleCardViews">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="visible part two"/>
</RelativeLayout>
<com.github.aakira.expandablelayout.ExpandableRelativeLayout
android:id="@+id/expandable_layout_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ael_expanded="false"
app:ael_duration="500"
app:ael_interpolator="linear"
app:ael_orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="expandable part two"/>
</com.github.aakira.expandablelayout.ExpandableRelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
What I want to achieve is click on collapsed cardVie to expand it's expandable part, while collapsing the collapsing the other cardview. At the same time, I want to keep both cardviews inside the screen boundaries. It should look like that.
+--LinearLayout---+
| +--CardView1---+|
| |visible part ||
| |--------------||
| |exppanded part||
| |80% of screen|||
| | ||
| +--------------+|
| |
| +--CardView2---+|
| |visible part ||
| |20% of screen ||
| +--------------+|
+-----------------+
after the user clicks on first CardView's visible part (vise versa):
+--LinearLayout---+
| +--CardView1---+|
| |visible part ||
| |20% of screen ||
| +--------------+|
| +--CardView2---+|
| |visible part ||
| |--------------||
| |exppanded part||
| |80% of screen|||
| | ||
| +--------------+|
+-----------------+
For the moment, in order to keep both card views inside the screen while collapsing or expanding, tried to change the cardviews weight attribute programmatically done like this. This solution keeps both cardviews inside the screen but the transition animation is not smooth at all.I'm suspecting that the use of ExpandableRelativeLayout is causing the problem.
Anyone faced the same problems and came up with a solution? Any help is appreciated!!