stateful drawable not finding other drawables
When creating a stateful drawable, I cannot find the other drawables (9-patch images) that are there - i get no "suggestions" ("intelliSense").
But if I try to find drawables in another XML-file there is no problem.
this is my stateful drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/view_background_pressed" />
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/view_background_normal" />
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/view_background_pressed" />
<item
android:drawable="@drawable/view_background_normal" />
</selector>
the "view_background_pressed" etc are all there, and they can be found in other XML-files but not in the statefule drawable.
Any ideas?
Asked by: Chelsea598 | Posted: 24-01-2022
Answer 1
It's quite possible that it's just Eclipse being funny. Have you tried cleaning the project from Project → Clean?
Or restarting Eclipse?
You can also check the output of aapt
to check that there isn't a subtle resource compilation problem somewhere that you're missing.
You can enable more output in the Eclipse console by going to:
Preferences → Android → Build → Build output → Verbose
Then, as you execute a build (or Eclipse attempts to build automatically), you'll see the aapt
output in the Console view (you may need to select the Android sub-console).
Answer 2
If you wan't to use custom shapes you need to make them in the same XML like this:
<?xml version="1.0" encoding="utf-8"?>
<item android:state_pressed="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/lichtblauw"/>
<corners
android:radius="5dp"/>
<stroke
android:width="1px" android:color="@color/donkergrijs" />
</shape>
</item> <!-- pressed -->
<item android:state_focused="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/lichtblauw"/>
<corners
android:radius="5dp"/>
<stroke
android:width="1px" android:color="@color/donkergrijs" />
</shape>
</item> <!-- focused -->
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/blauw"/>
<corners
android:radius="5dp"/>
<stroke
android:width="1px" android:color="@color/donkergrijs" />
</shape>
</item> <!-- default -->
Answered by: Carlos801 | Posted: 25-02-2022
Similar questions
android - Refresh list of drawables in Eclipse?
When I add drawable resources to my project they do not show up in the list of drawables in the Reference Chooser. I checked the R file and there are references for the files.
I have tried refreshing the project, cleaning the project, and fixing project properties and nothing seems to help. Sometimes a couple will randomly show up in there, but not all of them.
The only consistent way I can get them to sh...
android - Display a gallery of images that are stored as Drawables in a List
I am trying to modify this example:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
But instead of displaying images that are resources, I want to display Drawables that I currently am storing in a List.
Can anyone instruct me on how I would modify
Android: access drawables outside an activity
How do access a drawable which resides in my project's res/drawable folder from outside an activity?
The component which handles the loading of images is generic and is not inside any activity. I would like to display an image from res/drawable in case it can't be fetched from the web.
Thanks, Rob
How to use default Android drawables
What is the best approach when using default Android drawables? Should I use android.R.drawable or should I copy the drawables in my project and use R.drawable?
Is there any risk, that in a newer version of Android, some of the default drawables are removed or resized? Or, affect in some negative way, the look of my app? Also, which of the drawables in the Android source code are considere...
bug in android 2.1 xml drawables?
Looking at the following image, the button on the left is android 2.1, the one on the right is 2.2:
As you can see the corners on the left image are not being applied correctly, but they look perfect in 2.2. The xml I'm using is here:
<layer-list xml...
android - multiple drawables from one xml file
I want to use a number of ShapeDrawables in my application, which are all similar, but with different colours etc. Obviously I could just define them all in separate xml files, but is there a more efficient way to have one xml definition, instantiate various objects and change the colour either in code or xml? You could perhaps do this by calling mutate() on one ShapeDrawable defined in xml, but this returns a Drawable, ra...
java - Dealing with drawables for various screens sizes
I have observed from the HDPI, MDPI and LDPI icons from a new Android project, they are in the ratio of 6:4:3 (72:48:36). So would it be a good idea to scale my other drawables in the same ratio? If not what is the best way to scale drawable resources for an application for deployment?
android - how drawables resources stored on device
guys, I wonder if you put images for each density type (low/medium/high) and there are quite a few of them, won't it increase the size of application footprint on internal memory?
I would hope that android will put only needed resource file from apk to the actual application folder. Can somebody confirm that?
Android - Reduce the memory usage of Bitmap Drawables
I have a map in my application that shows locations from Gowalla. I use an ItemizedOverlay with a simple default marker, but as the items are drawn, I swap the default marker out with the location's icon downloaded 9and cached on disk) from Gowalla.
The problem is that if there are a lot of locations on screen (say 30), the size of the bitmaps in memory is enough to crash the activity. To prevent this, I only keep...
android - Why does the official Google IO app only have drawables that support hdpi and yet look fine on my small ldpi device?
I was looking at the source code of the open source Google IO App for android, and I relazied that they only have drawables in the "drawables-hdpi" (with only 2 exception out of 50 or so).
Reading the android guides and articles, I came to think that we need to support different screen sizes and resolution, but Google's IO app, which is supposed to reflect good GUI design patterns only has drawables for hdpi. ...
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android