I'm adding cards in a nested scrollview. The card elevation automatically increases for the cards that are lower down the order in the LinearLayout. To understand the issue, notice the card elevation between first and last cards. The last card has a darker shadow than the first one, though the cards are same. How to resolve?
Using appcompat v7:22.+ as dependency for v7 library.
This is my card view layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="1dp"
android:layout_marginBottom="10dp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="10dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/hint"
android:layout_width="0dp"
android:text="ABC"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/textHint"/>
<TextView
android:id="@+id/description"
android:layout_width="0dp"
android:text="DEFG BHJHKJ"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"/>
</LinearLayout>
</android.support.v7.widget.CardView>
This is how I'm using the card view:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingtoolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
layout="@layout/shared_activity_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:contentInsetStart="0dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f3f3f3"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:id="@+id/description"
android:lineSpacingMultiplier="1.5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<include
android:id="@+id/date"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/confirmation"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/admit"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/meeting_point"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/pickup_time"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/dropoff_time"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/cancellation"
layout="@layout/custom_detail_item_card" />
</LinearLayout>
<!--</android.support.v7.widget.CardView>-->
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
This is the output: https://i.stack.imgur.com/TkfNO.jpg