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

167 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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

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