All Apps header shadow is drawn incorrectly

Bug: 29777304
Change-Id: I9ead05b28d1d57dd6a157126637296a97e3f7058
This commit is contained in:
Peter Schiller committed 2016-06-27 18:59:32 -07:00
1 parent 1b65c6e97c
commit cbea086284
2 files changed
+34 -3

No files matched your search

@@ -2,6 +2,7 @@ package com.android.launcher3.allapps;
import android.annotation.TargetApi;
import android.content.res.Resources;
import android.graphics.Outline;
import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
@@ -82,11 +83,31 @@ public abstract class HeaderElevationController extends RecyclerView.OnScrollLis
public ControllerVL(View header) {
mHeader = header;
mHeader.setOutlineProvider(ViewOutlineProvider.BOUNDS);
Resources res = header.getContext().getResources();
Resources res = mHeader.getContext().getResources();
mMaxElevation = res.getDimension(R.dimen.all_apps_header_max_elevation);
mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);
// We need to provide a custom outline so the shadow only appears on the bottom edge.
// The top, left and right edges are all extended out, and the shadow is clipped
// by the parent.
final ViewOutlineProvider vop = new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
final View parent = (View) mHeader.getParent();
final int left = parent.getLeft(); // Use the parent to account for offsets
final int top = view.getTop();
final int right = left + view.getWidth();
final int bottom = view.getBottom();
outline.setRect(
left - (int) mMaxElevation,
top - (int) mMaxElevation,
right + (int) mMaxElevation,
bottom);
}
};
mHeader.setOutlineProvider(vop);
}
@Override