Reputation: 164
first, sorry if my english is not correct, (i'm french) and I've not find the solution for my problem in french websites, so i try here !
In my app, I want to show 7 Buttons with graphisms I created with the GIMP. So I use, in the XML code for my Buttons (here for my first button) :
android:background="@drawable/change_my_button1"
-change_my_button1 is an XML file :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:state_enabled="false"
android:drawable="@drawable/button-1" />
<item android:state_pressed="true" android:drawable="@drawable/button1-2" />
<item android:state_enabled="true"
android:drawable="@drawable/button1" />
If I press the button, its aspect change. All of that works perfectly with my button1, button2 and button3.
But when I apply this method for my button4, the app crashs and i have a message "Unfortunatly, the application my_app has stoped"
I thought my images "button4" and "button4-2" are wrong but no ! When I delete the code line
android:background="@drawable/change_my_button1"
from the XML code of my first Button, then the image for my fourth Button works perfectly... Maybe the res/drawable/ folder may contain only a restrict number of images ? I've tried to put those two images in several res/drawable/ folders, but it's not working...
I hope you'll understand my problem...
Please help me ! That is a pain in the ass for me...
Thanks ! :)
Upvotes: 0
Views: 226
Reputation: 12365
Your resources are to big and you get OutOfMemoryError
. You have to scale your resources for screen resolution which you support. I mean xxhdpi xhdpi hdpi etc. Probably all your resources are in drawable folder. It is wrong. They should be in drawable-xxhdpi, drawable-xhdpi, etc folders with proper size with proportions:
hdpi = mdpi * 1.5
xhdpi = mdpi * 2
xxhdpi = mdpi *3
Upvotes: 1