android:TextView设置背景色和文本颜色

来源:互联网 发布:yy头像psd源码在线制作 编辑:程序博客网 时间:2024/05/21 18:42

设置TextView控件的背景色和文本颜色很简单,如下:

textView01 = (TextView)findViewById(R.id.textView01); textView02 = (TextView)findViewById(R.id.textView02); //设置背景色 textView01.setText("设置了背景色黑色"); //从资源文件中加载颜色 textView01.setBackgroundDrawable( getResources().getDrawable(R.drawable.green)); //设置文本颜色(如透明色:Color.TRANSPARENT) textView02.setTextColor(Color.MAGENTA); textView02.setText("设置文本颜色");


原文地址:android:TextView设置背景色和文本颜色 | http://orgcent.com/android-textview-background-color/