private static Drawable createArrowIcon ( Context context , int width , int height , int color , ExpandDirection expandDirection ) { Bitmap canvasBitmap = Bitmap . createBitmap ( width , height , Bitmap . Config . ARGB_8888 ) ; Canvas canvas = new Canvas ( canvasBitmap ) ; Paint paint = new Paint ( ) ; paint . setStyle ( Paint . Style . FILL_AND_STROKE ) ; paint . setStrokeWidth ( 1 ) ; paint . setColor ( color ) ; paint . setAntiAlias ( true ) ; Path path = new Path ( ) ; path . setFillType ( Path . FillType . EVEN_ODD ) ; switch ( expandDirection ) { case UP : path . moveTo ( 0 , ( height / 3 ) * 2 ) ; path . lineTo ( width , ( height / 3 ) * 2 ) ; path . lineTo ( width / 2 , height / 3 ) ; path . lineTo ( 0 , ( height / 3 ) * 2 ) ; break ; case DOWN : path . moveTo ( 0 , height / 3 ) ; path . lineTo ( width , height / 3 ) ; path . lineTo ( width / 2 , ( height / 3 ) * 2 ) ; path . lineTo ( 0 , height / 3 ) ; break ; } path . close ( ) ; canvas . drawPath ( path , paint ) ; return new BitmapDrawable ( context . getResources ( ) , canvasBitmap ) ; }
Creates arrow icon that depends on ExpandDirection