Amin
Amin

Reputation: 27

Can not Set Activity Background

I tried to set a full screen background for my main layout in android studio 2.3.3.

But the problem is even when I convert my image for all the dpi's but stay cant see my image in my background i use (android:background="Drawble/bg-main" ) not working i use ImageView to set it but its not working and show this error (failed to instantiate one or more class)

I don't know what to do and I am very newbie in android developing thanks for helping me see my screen shot to understand completely

Screen Shot Error 1:

enter image description here

Screen Shot Error 2:

enter image description here

Upvotes: 0

Views: 132

Answers (4)

Akash Soni
Akash Soni

Reputation: 11

Because drawable name Bg-Main its not acceptable..

you r using bg_main special character not allow(B,-)

Upvotes: 1

Akhilesh Awasthi
Akhilesh Awasthi

Reputation: 2708

    '-' is not a valid file-based resource name character:
 File-based resource names must contain only lowercase a-z, 0-9, or underscore

Change your image name as bg_main for all. It will do.

Upvotes: 1

R.R.M
R.R.M

Reputation: 790

You cannot use capital letters or - in drawable image name. Just try to rename your image as bg_main and your problem will be solved.

Upvotes: 3

isamirkhaan1
isamirkhaan1

Reputation: 759

Use _ instead of -. So, your drawable should look like this bg_main/ P.S: never use - in XML naming

Upvotes: 2

Related Questions