0

I 'm trying to set background of my main activity in my application something like in this way:-

 <?xml version="1.0" encoding="utf-8"?>
 <android.support.v4.widget.DrawerLayout  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/background"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

but the code gives me error:

The following classes could not be instantiated: - android.support.v4.widget.DrawerLayout (Open Class, Show Exception, Clear Cache)

i don't know why this happens.@drawable/background is an image of resolution 1080x1920. I tried to give a color instead of image and it works very well then.But got errors when it comes to an image.Am i missing something? Please help me out.

Midhun
  • 744
  • 2
  • 15
  • 31
  • What is your image file? Is it a properly formatted png? – Colin Oct 17 '15 at 01:48
  • Could you post the full stack trace? – Abdullah Oct 17 '15 at 02:40
  • As pointed out my image was not `.png` format. I put another image with `.png` format but this time it's not displaying in pre-lollipop devices.Where as it's working in lollipop and after.Working in marsmallow. – Midhun Oct 17 '15 at 14:32

1 Answers1

0

Try setBackground in code like:

layout.setBackground(getResources().getDrawable(R.drawable.background));
AndroidLTG
  • 91
  • 1
  • 11