简体   繁体   中英

how to set background image in relative layout programmatically in on create?

I used the code layout.setbackgroundresource(R.drawable.image) in on create method to set background image of layout. But when i try to run on device it stopped working without opening the screen. Please help in this problem.

this is the code which i wrote in oncreate method mainlayout.setBackgroundResource(R.drawable.darkbackground);

MainActivity:

enter image description here

error logcat:

enter image description here

it crashes my app when opening the app.

The issue is not with the Image view. Its because of the Google Api ie Firebase Analytics.

Try disable the Firebase analytics in your code and run the app. If it's working, then fix the Firebase issue.

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