15

Lollipop has all those new functions for the "View" class. What exactly are the differences between them, and why do we need so many functions for them?

I've read the docs, and I want to understand (or better understand) the difference and the need for each of them, so that I would know when to use each of them :

  1. elevation

base z depth of the view

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol elevation.

So this is what it starts from?

  1. translationZ

translation in z of the view. This value is added to its elevation.

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol translationZ.

So this is added in addition to the "elevation" ? Why is it needed?

  1. And, the most confusing : setZ

Sets the visual z position of this view, in pixels. This is equivalent to setting the translationZ property to be the difference between the x value passed in and the current elevation property.

I don't understand the explanation of this at all. Does this affect the shadow? What is it used for? To handle the case that 2 views have the same total elavation value ? Would Animating this value change the way a view is shown?

Dennis Sheil
  • 719
  • 4
  • 16
android developer
  • 106,412
  • 122
  • 641
  • 1,128

0 Answers0