我正在创建一个基于sharedpreferences字符串的动态接口。
继承我的代码
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
CreateInterface();
}//End-OnCreate
public void CreateInterface()
{
ScrollView sv = new ScrollView(this);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
TableLayout tl = new TableLayout(this);
TableRow[] tr = null;
// Here is a loop that creates tablerow, create button in that, and add tablerow to tablelayout tl. This part is irrelevant couse it works perfectly.
ll.addView(tl);
sv.addView(ll);
setContentView(sv);
}
现在,我想改变屏幕的背景颜色。我该怎么做呢?
答案 0 :(得分:1)
使用以下方法设置ScrollView或LinearLayout背景颜色。
sv.setBackgroundColor(); or ll.setBackgroundColor();
使用getResources().getColor(R.color.yourColorID);
答案 1 :(得分:1)
ll.setBackgroundColor()应该完成这项工作。