I insert a toolbar. At the top, it overlaps the cardview part. At the bottom of the card is also cropped (You can not see the shadows and rounding). How to fix this ailment?

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.hubble.news.activities.ReadingPostActivity"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/reading_post_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/reading_post_card_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="4dp" android:layout_marginEnd="4dp" android:layout_marginStart="4dp" android:layout_marginTop="4dp" card_view:cardCornerRadius="4dp" card_view:cardElevation="3dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" android:gravity="center" android:orientation="vertical"> <ImageView /> <TextView /> <TextView /> </LinearLayout> </android.support.v7.widget.CardView> </android.support.v4.widget.NestedScrollView> 

    1 answer 1

    In NestedScrollView you need to add a marginTop with the value:

    ?android:attr/actionBarSize

    And in order that the shadow from the bottom is not cut off to do with NestedScrollView layout_height = match_parent

    • From above it helped, but from below it cuts - alexmx