how to give textcolor to textview in class file

こ雲淡風輕ζ 提交于 2019-12-10 21:45:13

问题


I am creating the custom textview i want to give black textcolor to this textview. how can i set textcolor. my code is

TextView textview = new TextView(this);

textview.setText("Please follow this Description");

setContentView(_textview);

when i use textview.setTextColor(Integer.parseInt("#000000"))

Thanks in advance


回答1:


Use Color.parseColor():

textview.setTextColor(Color.parseColor("#000000"));

another option is to use HEX integer directly:

textview.setTextColor(0xff000000);



回答2:


I found the solution it is done by using the code

textview.setTextColor(Color.BLACK);



来源:https://stackoverflow.com/questions/3572773/how-to-give-textcolor-to-textview-in-class-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!