开发者

Android dynamic background

I am somewhat of a new android developer and have a question regarding changing the background dynamically at runtime.

Wh开发者_如何转开发at I want to do is set a background color in a LinearLayout Tag, and later change that background color in my activity class. This code below is not working. Am I missing something or is this the wrong approach for trying to change the background color in a linear layout

LinearLayout lv = (LinearLayout)findViewById(R.id.ChoiceLayout);
lv.setBackgroundColor(0x000080);

Thanks in advance


First thing I've noticed is that your color has ALPHA = 0x00. Which makes it transparent. Try changing to

lv.setBackgroundColor(0xFF000080);


AFAIK, that should work fine. Use hierarchyviewer to try to diagnose what is going wrong.


already answered in another post , unfortunately i don't know that link but know the solution.

use

lv.setBackgroungColor(GetResources().getColor(int color));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜