tags:

views:

455

answers:

4

Creating a Drawable that is completely empty seems like a common need, as a place holder, initial state, etc., but there doesn't seem to be a good way to do this... at least in XML. Several places refer to the system resource @android:drawable/empty but as far as I can tell (i.e., it's not in the reference docs, and aapt chokes saying that it can't find the resource) this doesn't exist.

Is there a general way of referencing an empty Drawable, or do you end up creating a fake empty PNG for each project?

+1  A: 

Kai, I don't know why this is the case, but I've gotten the same issue. I think it might be related to the version of Android you're compiling for? In any case, I found that simply using @android:id/empty where you would use @android:drawable/empty does the trick.

John LeBoeuf-little
A: 

Thanks a lot John! This did the trick for me as well.

Matt Langston
+3  A: 

For me it did'nt work when I tried to use @android:id/empty when making an empty drawable. For me, @android:color/transparent was the one.

Emil
+1  A: 

For me, using @android:drawable/empty would show an error and prevent compiling. Using @android:id/empty fixed the error and let me compile, but showed "NullPointerException: null" in the Eclipse Layout editor. I changed it to @android:color/transparent and now everything is fine.

I can't vote up yet or I would have up'ed Emil's answer.

wirbly