2010-09-07 35 views

回答

34
TypedArray array = getTheme().obtainStyledAttributes(new int[] { 
    android.R.attr.colorBackground, 
    android.R.attr.textColorPrimary, 
}); 
int backgroundColor = array.getColor(0, 0xFF00FF); 
int textColor = array.getColor(1, 0xFF00FF); 
array.recycle(); 
+0

太謝謝你了。 – arcs 2016-05-24 19:17:28

0

背景

TypedArray array = context.getTheme().obtainStyledAttributes(new int[] { 
     android.R.attr.windowBackground}); 
    int backgroundColor = array.getColor(0, 0xFF00FF); 
    array.recycle(); 
    view.setBackgroundColor(backgroundColor);