简体   繁体   中英

Programmatically change activity background image within OnCreate

I have made one of my apps compatible with Android versions prior to 3.2 using Action Bar Sherlock. The background image I have used for each activity within this app does not look good in the earlier versions of Android.

Therefore, I would like to remove the background image for each activity in the app ONLY if the Android version being used is below 3.2. I believe I can implement this within OnCreate, but I'm not exactly sure how. All of the activity attributes have been set in the layout files themselves. Can someone give me example code on how to programmatically change the background within OnCreate for the earlier Android versions? Thanks!

Check this

Do something like:

if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2){
    // remove background picture 
}
if (android.os.Build.VERSION.SDK_INT < 13) { 
yourlayout.setBackgroundResource(resourceID);     
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM