Sep*_*phy 15
你尝试过其中一个:
yourLayout.setBackgroundColor(int color);
yourLayout.setBackgroundDrawable(Drawable d);
yourLayout.setBackgroundResource(int resid);
Run Code Online (Sandbox Code Playgroud)
如果不自己刷新,这应该给它一个提升:
yourLayout.invalidate();
Run Code Online (Sandbox Code Playgroud)
kco*_*ock 11
我现在在工作,所以我无法测试,但我相信这应该有效:
LinearLayout linLay = (LinearLayout) findViewById(R.id.theLinearLayoutId);
//set background to a color
linLay.setBackgroundColor(Color.parseColor("#404040"));
//set background to a drawable
linLay.setBackgroundDrawable(drawableItem);
//set background to a resource
linLay.setBackgroundResource(R.id.backgroundResource);
Run Code Online (Sandbox Code Playgroud)