"@+id/title"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:gravity="center"        android:text="头条" />
   public TextView(Context context) {        this(context, null);    }    public TextView(Context context, @Nullable AttributeSet attrs) {        this(context, attrs, com.android.internal.R.attr.textViewStyle);    }    public TextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {        this(context, attrs, defStyleAttr, 0);    }

通常我们这样添加textview,
com.android.internal.R.attr.textViewStyle
系统默认指定了灰色文字(goole原生的是灰色,不排除一些厂家修改底层,自定义颜色)。
那么这个默认的灰色的颜色值到底是多少????

看一下sdk中的灰色值:

public class Color {    @ColorInt public static final int BLACK       = 0xFF000000;    @ColorInt public static final int DKGRAY      = 0xFF444444;    @ColorInt public static final int GRAY        = 0xFF888888;    @ColorInt public static final int LTGRAY      = 0xFFCCCCCC;    @ColorInt public static final int WHITE       = 0xFFFFFFFF;    @ColorInt public static final int RED         = 0xFFFF0000;    @ColorInt public static final int GREEN       = 0xFF00FF00;    @ColorInt public static final int BLUE        = 0xFF0000FF;    @ColorInt public static final int YELLOW      = 0xFFFFFF00;    @ColorInt public static final int CYAN        = 0xFF00FFFF;    @ColorInt public static final int MAGENTA     = 0xFFFF00FF;    @ColorInt public static final int TRANSPARENT = 0;

可能是 public static final int GRAY = 0xFF888888;吗???
不确定,我们可以自己验证:

  TextView tv = ((TextView) view.findViewById(R.id.title));        int color = tv.getCurrentTextColor();        Log.d("lihui","1 color---    "+color);

12-05 17:44:58.609 16080-16080/com.example.lihui20.testhttp D/lihui: 1 color— -1979711488

 textView1.setTextColor(Color.GRAY);        int color = textView1.getCurrentTextColor();        Log.d("lihui","2 color---   "+color);

12-05 17:52:56.389 23513-23513/com.example.lihui20.testhttp D/lihui: 2 color— -7829368

使用win7计算器工具
Color.GRAY:
十进制下,用2个字节表示:
-7829368
对应16进制:
FF888888
那么:
原生的默认颜色值:
十进制下,用2个字节表示: -1979711488
对应16进制:
8A000000

8A000000 :
8A表示颜色深度
000000表示黑色

希望对开发者有用,谢谢

更多相关文章

  1. Android练习—修改背景颜色
  2. 设置ScrollView滚动条的颜色
  3. 字节跳动正式启动2021届秋季校招!这份字节跳动历年校招Android面
  4. android 自定义progressbar进度条颜色
  5. android 颜色对应值
  6. android给View设置边框 填充颜色 弧度
  7. Android颜色值XML文件
  8. android 颜色选择器
  9. Android如何使用XML创建一个环形渐变颜色图片

随机推荐

  1. 在Eclipse中查看Android(安卓)SDK的源代
  2. 修改Android默认背光值
  3. Android(安卓)game engine list
  4. Android视频应用去广告学习实践
  5. Android(安卓)Bitmap 相关
  6. android中获取文字的宽度
  7. Android(安卓)UI架构(四)--SurfaceFlinge
  8. 四十二、Android完全退出应用程序
  9. android SDK 环境变量配置+ADT安装
  10. Android(安卓)RIL总体架构介绍