/** Initialize shadows, color overlay, and rounded corners. All are optional. */ void initialize(int shadowType, boolean hasColorDimOverlay, int roundedCornerRadius) { if (mInitialized) { throw new IllegalStateException(); } mInitialized = true; mRoundedCornerRadius = roundedCornerRadius; mRoundedCorners = roundedCornerRadius > 0; mShadowType = shadowType; switch (mShadowType) { case SHADOW_DYNAMIC: mShadowImpl = ShadowHelper.getInstance() .addDynamicShadow(this, mUnfocusedZ, mFocusedZ, mRoundedCornerRadius); break; case SHADOW_STATIC: mShadowImpl = StaticShadowHelper.getInstance().addStaticShadow(this); break; } if (hasColorDimOverlay) { setWillNotDraw(false); mOverlayColor = Color.TRANSPARENT; mOverlayPaint = new Paint(); mOverlayPaint.setColor(mOverlayColor); mOverlayPaint.setStyle(Paint.Style.FILL); } else { setWillNotDraw(true); mOverlayPaint = null; } }
/** * {@link #prepareParentForShadow(ViewGroup)} must be called on parent of container before using * shadow. Depending on sdk version, optical bounds might be applied to parent. */ public static void prepareParentForShadow(ViewGroup parent) { StaticShadowHelper.getInstance().prepareParent(parent); }
/** Return true if the platform sdk supports shadow. */ public static boolean supportsShadow() { return StaticShadowHelper.getInstance().supportsShadow(); }