The design is a Linearlayout with a cardivew inside and a background color, that simple.
By clicking on any view (View 1, View 2 ...) other layouts are added dynamically. These new layouts "push" the Linearlayout that holds the Cardview. I think that this does not influence the effect I want to achieve.
I would like to get the effect that you see in the next image.
Any ideas?
For that You need to use ConstraintLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/abc"
android:layout_width="match_parent"
android:layout_height="150dp"
app:layout_constraintTop_toTopOf="linearLayout"
app:layout_constraintBottom_toTopOf="linearLayout"/>
<LinearLayout>
....Your Layout Code.....
</LinearLayout/>
</android.support.constraint.ConstraintLayout>