分享

Android设置TextView颜色setTextColor

 _私_房_菜_ 2012-08-22

TextView tv = new TextView(this);

tv.setText("Test set TextView's color.");

//方案一:代码中通过argb值的方式

tv.setTextColor(Color.rgb(255, 255, 255));

//方案二:代码中通过xml中的颜色设置

Resources resource = (Resources) getBaseContext().getResources();

ColorStateList csl = (ColorStateList) resource.getColorStateList(R.color.my_color);

if (csl != null) {

tv.setTextColor(csl);

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多