I tried both features and I don't know really why I should use elevation instead of translationz or viceversa.
Both generate shadow when I used them.
I should use at same time (with the same value)? I should use just one?
Thank you in advance!
EDIT:
I did a visual comparison to can see it clearly:
The conclusion that I get is (at least with this range of 0 to 16 dp) one of them is dispensable.
I see the same shadow in 8 vs 8 and 16 vs 16 and the same shadow in 16 vs 8+8.
But I haven't a great vision, what do you think guys?
TranslationZ is a dynamic property used for animation. Basically it's needed to nicely handle elevation changes. When you press a button, its elevation remains unchanged and its translationZ is being animated.
Elevation helps users understand the relative importance of each element and focus their attention to the task at hand. The elevation of a view, represented by the Z property, determines the visual appearance of its shadow: views with higher Z values cast larger, softer shadows.
That is because the actual Z value is the sum of the elevation
and the translationZ
From the docs, the elevation
is "base z depth of the view" and this is a static variable, while translationZ is dynamic.
So elevation
is your start value and for animations you should use translationZ
.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With