以编程方式设置背景色 [英] Set Background color programmatically

查看:105
本文介绍了以编程方式设置背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试以编程方式设置背景颜色,但是当我设置每种颜色时,背景是黑色,但任何颜色背景都像应用程序主题一样是白色.

I try to set background color programmatically but when I set every one of my colors, the background being black but with any color background being white like the application theme.

View someView = findViewById(R.id.screen);
View root = someView.getRootView();
root.setBackgroundColor(color.white);

您看到代码了吗?

推荐答案

我不明白您的问题……当我设置每种颜色时"是什么意思?试试这个(原始答案中的"#fffff"更改为"#ffffff"

I didn't understand your question ... what do you mean by "when i set every one of my colour"? try this (edit: "#fffff" in original answer changed to "#ffffff"

  yourView.setBackgroundColor(Color.parseColor("#ffffff"));

这篇关于以编程方式设置背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆