我有一個linearLayout作爲我的android xml文件中的主佈局。背景設置爲「@ drawable/window_background_red」。在活動內部(運行時),我想將其設置爲「@ drawable/window_background_green」。如何調整頂部佈局的背景屬性
window_background_green.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:type="linear"
android:startColor="#000000"
android:endColor="#004400"
android:angle="-90"
/>
</shape>
</item>
</selector>
重複: http://stackoverflow.com/questions/4761686/how-to-set-background-color-of-activity-to-white-programmatically –