TextView tv = (TextView)solo.getView(TextView.class,4);
ColorDrawable dr = (ColorDrawable) tv.getBackground();
int col_int = dr.getColor();
Log.d("TestPhone", Color.RED+" 红色的数字");
Log.d("TestPhone", col_int+" 获取的颜色");
ColorDrawable dr = (ColorDrawable) tv.getBackground();
int col_int = dr.getColor();
Log.d("TestPhone", Color.RED+" 红色的数字");
Log.d("TestPhone", col_int+" 获取的颜色");
assertEquals("The result is ", col_int, Color.RED);
如下图: