在android視圖中如何設置一個背景的顏色?
Activity中的代碼:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View v = new View(this);
setContentView(v);
v.setBackgroundColor(23423425);
}
卻得到的是黑屏。
View view = new View(this);
view.setBackgroundColor(Color.BLACK);
或者view.setBackgroundColor(十六進制顏色值)
或者上面那方法
看Color類中的
public static final int BLACK = 0xFF000000;
public static final int DKGRAY = 0xFF444444;
public static final int GRAY = 0xFF888888;
public static final int LTGRAY = 0xFFCCCCCC;
public static final int WHITE = 0xFFFFFFFF;
public static final int RED = 0xFFFF0000;