What do I need to put in for an attribute if I want to put a null there?
For example, this piece of code:
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/ef_gradient_blue" />
<item android:drawable="@null" />
</transition>
But this won’t work, as my app crashes when it tries to load this drawable. I need it to be null, so it can make a transition from fully opaque to completely see through.
In my Java, I load it like this:
mTransitionBlue = (TransitionDrawable)mProjectResources.getDrawable(R.drawable.transition_blue);
But I get a runtime exception from this, saying it can’t find the transition_blue.xml, which is the XML specified before. So how do I achieve this?
You should use a transparent drawable there (android lib has it predefined):
the
@android:color/transparent‘s value is#00000000. It’s important to have the first two digits 0, since they define the alpha value of the color (the rest is red, green and blue).So you can use
as well, or redefine it among your colors.
For reference you could take a look at the Android Developers
2D GraphicsandTransition Drawablesarticles.