private static Bitmap createEdgeShadow ( @ NonNull final Context context , final int elevation , @ NonNull final Orientation orientation , final boolean parallelLight ) { if ( elevation == 0 ) { return null ; } else { float shadowWidth = getShadowWidth ( context , elevation , orientation , parallelLight ) ; int shadowColor = getShadowColor ( elevation , orientation , parallelLight ) ; int bitmapWidth = ( int ) Math . round ( ( orientation == Orientation . LEFT || orientation == Orientation . RIGHT ) ? Math . ceil ( shadowWidth ) : 1 ) ; int bitmapHeight = ( int ) Math . round ( ( orientation == Orientation . TOP || orientation == Orientation . BOTTOM ) ? Math . ceil ( shadowWidth ) : 1 ) ; Bitmap bitmap = Bitmap . createBitmap ( bitmapWidth , bitmapHeight , Bitmap . Config . ARGB_8888 ) ; Canvas canvas = new Canvas ( bitmap ) ; Shader linearGradient = createLinearGradient ( orientation , bitmapWidth , bitmapHeight , shadowWidth , shadowColor ) ; Paint paint = new Paint ( ) ; paint . setAntiAlias ( true ) ; paint . setDither ( true ) ; paint . setShader ( linearGradient ) ; canvas . drawRect ( 0 , 0 , bitmapWidth , bitmapHeight , paint ) ; return bitmap ; } }
Creates and returns a bitmap which can be used to emulate a shadow which is located at a corner of an elevated view on pre - Lollipop devices .