1

I'm trying to utilize elevation attributes to display drop shadows. As you can see from the images, it displays fine in Android Studio but when run on the device, one of the drop shadows disappears. Why would one show but not the other?

Image from Android Studio

image

Screenshot from Marshmallow device image

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white_80"
>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/booking_details_top_block"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:elevation="4dp"
        >

        <LinearLayout
            android:id="@+id/image_block"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="center_horizontal"
            >

            <ImageView
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_margin="8dp"
                android:background="@color/black"
                />
            <ImageView
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_margin="8dp"
                android:background="@color/black"
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center_horizontal"
            android:layout_margin="16dp"
            android:padding="16dp"
            android:background="@drawable/booking_detail_date_background"
            >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                tools:text ="Tuesday, September 1"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                tools:text ="4:00 PM - 6:00 PM"
                />

        </LinearLayout>

        <TextView
            android:id="@+id/bookings_status"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="4dp"
            android:paddingBottom="4dp"
            android:paddingRight="16dp"
            android:paddingLeft="16dp"
            android:gravity="center_horizontal"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/status_background"
            android:textColor="@color/white"
            tools:text="CONFIRMED"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center_horizontal"
            android:layout_marginTop="8dp"
            android:padding="8dp"
            >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                android:text ="@string/booking_details_brig"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="4dp"
                tools:text ="Lorena M."
                />

        </LinearLayout>

        <RatingBar
            android:id="@+id/rate_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:stepSize="1"
            style="@style/Widget.CustomRatingBar"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="24dp"
            android:layout_marginRight="@dimen/dialog_horizontal_margin"
            android:layout_marginLeft="@dimen/dialog_horizontal_margin"
            />
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"

            />
    </LinearLayout>

    <include layout="@layout/widget_booking_details" />



</LinearLayout>

widget_booking_details

>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:elevation="2dp"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="@dimen/booking_details_margin"
            android:paddingTop="@dimen/booking_details_padding"
            android:paddingBottom="@dimen/booking_details_padding"
            android:layout_gravity="center_vertical"
            android:text="@string/booking_details_address"/>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical"
            android:layout_gravity="center_vertical"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tools:text="22 Phitsanulok Rd, apt. 3"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tools:text="Khwaeng Dusit, Dusit"/>
        </LinearLayout>


    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/white"
        android:layout_marginStart="@dimen/booking_details_margin"
        android:layout_marginEnd="@dimen/booking_details_margin"
        />
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="@dimen/booking_details_padding"
            android:paddingBottom="@dimen/booking_details_padding"
            >

            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginLeft="@dimen/booking_details_margin"
                android:paddingTop="4dp"
                android:paddingBottom="4dp"
                android:layout_gravity="center_vertical"
                android:text="@string/booking_details_services"/>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical"
                android:layout_gravity="center_vertical"
                >
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    tools:text="Waves after waves,"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    tools:text="Evening glam"/>
            </LinearLayout>

        </LinearLayout>

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/booking_details_margin"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:src="@drawable/up_arrow"
            android:background="@color/cream"
            />
    </RelativeLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/white"
        android:layout_marginStart="@dimen/booking_details_margin"
        android:layout_marginEnd="@dimen/booking_details_margin"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="@dimen/booking_details_padding"
        android:paddingBottom="@dimen/booking_details_padding"
        >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="@dimen/booking_details_margin"
            android:paddingTop="4dp"
            android:paddingBottom="4dp"
            android:layout_gravity="center_vertical"
            android:text="@string/booking_details_cost"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center_vertical"
            tools:text="24,600B"/>


    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/white"
        android:layout_marginStart="@dimen/booking_details_margin"
        android:layout_marginEnd="@dimen/booking_details_margin"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="@dimen/booking_details_padding"
        android:paddingBottom="@dimen/booking_details_padding"
        >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="@dimen/booking_details_margin"
            android:paddingTop="4dp"
            android:paddingBottom="4dp"
            android:layout_gravity="center_vertical"
            android:text="@string/booking_details_payment"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center_vertical"
            tools:text="Mastercard ending 1234"/>


    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/white"
        android:layout_marginStart="@dimen/booking_details_margin"
        android:layout_marginEnd="@dimen/booking_details_margin"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="@dimen/booking_details_padding"
        android:paddingBottom="@dimen/booking_details_padding"
        >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="@dimen/booking_details_margin"
            android:paddingTop="4dp"
            android:paddingBottom="4dp"
            android:layout_gravity="center_vertical"
            android:text="@string/booking_details_booking_ref"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center_vertical"
            tools:text="1639460503"/>


    </LinearLayout>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingTop="@dimen/booking_details_padding"
    android:paddingBottom="@dimen/booking_details_padding"
    android:background="@color/white"
    >

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginLeft="@dimen/booking_details_margin"
        android:paddingTop="4dp"
        android:paddingBottom="4dp"
        android:layout_gravity="center_vertical"
        android:text="@string/booking_details_booking_help"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center_vertical"
        android:text="@string/booking_details_booking_help_email"/>
    <!--TODO make email an actual link-->

</LinearLayout>

easycheese
  • 5,859
  • 10
  • 53
  • 87

1 Answers1

2

Odd solution but I merely had to put a background color in:

    <LinearLayout
        android:id="@+id/booking_details_top_block"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@color/white"
        android:elevation="4dp"
        >
easycheese
  • 5,859
  • 10
  • 53
  • 87