If you have ever had to make you own custom buttons for Android then you will have used a StateList Drawable; or you should have. Now if you look at the Android documentation for StatList Drawables then you will see that there is an option called “android:constantSize” that is said to behave like this:
Boolean. “true” if the drawable’s reported internal size remains constant as the state changes (the size is the maximum of all of the states); “false” if the size varies based on the current state. Default is false.
Now that is all well and good. I think it is telling me that if the size of the image does not change in any of the states then you should set this to true. My question would be: what benefit does setting this value to true have? Does it speed up rendering times? Is it more efficient in the background?
Essentially, what benefit will setting this attribute to true give me?
When the flag is set, the drawable computes a constant size once and uses that for all queries about its size. When the flag is not set, it queries the current drawable each time for its intrinsic width.