Skip to content
Advertisement

display image in a splash screen

I am a novice android developer. I am trying to create a splash screen. I have a png image. I have created an empty splash screen with a text box.I have 2 activities – MainActivity and SecondActivity.

code:

JavaScript

activity_main.xml:

JavaScript

But app:srcCompat=”@drawable/geeks” is in red color. Means it is not resolved. Where shall I copy the png image for the splash screen? I have not copied the image anywhere in android studio. Without the image view, the splash screen runs fine showing hello world.

Advertisement

Answer

first you need to put your image in res/drawable folder:

enter image description here

and then access it by app:srcCompat or android:src attribute of ImageView inside your activity_main.xml:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement