0xFF8E8F8A的值>整数MAX_VALUE.
由于设计上不会发生任何上溢或下溢引发异常的情况,因此它将被解释为Integer.MIN_VALUE,因为Integer.MAX_VALUE 1转换为Integer.MIN_VALUE.
因此,Long.intValue会将值转换为int,并使用给定的Integer.MAX_VALUE x值,其中x> 0,将从Integer.MIN_VALUE,即Integer.MIN_VALUE x偏移.
但是,从Integer javadoc:
An exception of type NumberFormatException is thrown if any of the
following situations occurs:
The first argument is null or is a string of length zero. […] The
value represented by the string is not a value of type int.
值0xFF8E8F8A的类型不是int,因此为NumberFormatException.
附带说明一下,我很确定ColorDrawable构造函数采用int格式,因为它采用了id而不是颜色的数字表示形式,但是老实说文档对此并不十分清楚.
请参阅R.color文档here.
最后说明-信用归因于此OP.
您可以使用新的ColorDrawable(Color.parseColor(yourHexString))获得更方便的方法.