qhutch / ElevationImageView

Imageview with elevation shadow
396 stars 46 forks source link

Shadow is drawn over system UI #8

Closed ValCanBuild closed 6 years ago

ValCanBuild commented 6 years ago

Issue is seen in the lower left corner of this GIF (recorded on a Nexus 5 running Marshmallow): shadow_issue

The Ico icon there is an ElevationImageView with the following properties:

    <com.qhutch.elevationimageview.ElevationImageView
        android:id="@+id/articleLogo"
        android:layout_width="38dp"
        android:layout_height="38dp"
        android:layout_marginStart="@dimen/grid_space_2x"
        android:importantForAccessibility="no"
        android:scaleType="centerCrop"
        android:elevation="4dp"
        app:layout_constraintBottom_toTopOf="@id/articleTitle"
        app:layout_constraintStart_toStartOf="parent"
        tools:src="@sample/logos"/>

While, clipShadow="false" does fix this issue it means the view needs padding attached to it which the design does not permit. In any case, I don't believe the shadow should really be attempting to draw over the system UI. Is there anyway to fix this?

This issue is not present on a Pixel XL running Oreo

qhutch commented 6 years ago

I could not reproduce your issue (even on an nexus 5 emulator running marshmallow) but I tried a new method to draw the shadow outside the view bounds, you can try version 1.7.1 (which is not in the readme yet, as I don't know if this solution is working), and tell me if this resolves your issue. If the parent view is the same size as your imageview, you may have to set android:clipChildren="false"

ValCanBuild commented 6 years ago

No, this doesn't work. In fact, now it looks like the shadow is clipped like how it was in 1.7 with setting clipShadow="true". Also, with your new code if you set clipShadow="true" the shadow doesn't draw.

screen shot 2018-05-11 at 10 40 59

qhutch commented 6 years ago

It's normal that the shadow doesn't draw with clipShadow="true", this was just for the test. Have you tried setting android:clipChildren="false" on all parents ?

ValCanBuild commented 6 years ago

the photo above is with clipChildren="false" set to all parents. And actually, even if that worked it's not great for my use case :(

qhutch commented 6 years ago

I will try to work it out over the weekend, will tell you if I find a solution

qhutch commented 6 years ago

Sorry for the delay, can you try with version 1.7.2 ? This version should work as version 1.7 but the image should not draw over the system UI (I'm sorry to ask you to test but I cannot reproduce this issue)

ValCanBuild commented 6 years ago

Hi @qhutch so 1.7.2 fixes the drawing over the navigation buttons for the Nexus 5 but there is still smudging happening on the status bar that can bleed into the toolbar:

smudging

qhutch commented 6 years ago

Can you try with v1.7.3 ? If this time it draws over system UI or the shadow is clipped, then I don't think I'll be able to find a solution

ValCanBuild commented 6 years ago

@qhutch, yeah! That works great! I can confirm shadow is not drawn over navigation controls or the status bar. Thanks for fixing it.

qhutch commented 6 years ago

You can now use v2.0 with attribute "forceClip" set to true