public static Integer parseWebColorAsAndroidColor ( String input ) { // Swap if input is #RRGGBBAA, but not if it is #RRGGBB Boolean swapAlpha = ( input . length ( ) == 9 ) ; try { Integer ret = Color . parseColor ( input ) ; if ( swapAlpha ) { ret = ( ret >>> 8 ) | ( ( ret & 0x000000FF ) << 24 ) ; } return ret ; } catch ( IllegalArgumentException e ) { logException ( e ) ; } return null ; }
The web standard for colors is RGBA but Android uses ARGB . This method provides a way to convert RGBA to ARGB .