Elevation — Basics, Shadows and Z-Coordinate in Android

Author: IT Sectr Published: 2026-02-28 Reading time: 9 min

Elevation is a fundamental concept of Material Design that defines the height of an element along the z-axis (perpendicular to the screen). Elevation is measured in dp and directly affects the size and blur of the shadow cast by the element. The higher the elevation, the closer the element is to the user and the more noticeable its visual weight. According to Material Design 3 (Google, 2026), the standard elevation for cards is 1 dp, for FloatingActionButton — 6 dp, for dialogs — 24 dp. Learn more about shadow implementation in the article on shadows in UI.

Key Takeaways

  • Elevation — the height of an element relative to the screen surface, measured in dp (Android).
  • In Android, elevation is controlled via the View property of the same name or through translationZ for animation.
  • OutlineProvider defines the shape of the element along which the elevation shadow is rendered.
  • Material Design 3 uses 5 basic elevation levels: 0, 1, 3, 6, 8, 12 and 24 dp.
  • On iOS there is no direct analogue of elevation — height is simulated via CALayer.shadow with parameters.

What is elevation?

Elevation is a metric introduced in Material Design (Google I/O 2014) that describes the position of an element along the z-axis. Unlike x and y (the two-dimensional plane of the screen), z is the height above the plane. Elevation is expressed in dp (density-independent pixels) and determines two visual effects: shadow, which becomes larger and blurrier as elevation increases, and drawing order (elements with higher elevation are drawn on top of elements with lower elevation).

Physical metaphor: imagine sheets of paper on a table. The higher the stack, the longer the shadow from the top sheet. Elevation in Material Design works exactly the same way — each element is a “digital sheet” at a certain height. When a user interacts with an element (presses a button, lifts a card), elevation temporarily increases — this is called “interaction elevation.”

According to Material Design Guidelines (Google, 2026), proper use of elevation improves interface scanability by 35%: users find interactive elements faster because they “stand out” above flat content. However, excessive elevation levels (more than 4) reduce this effect — if everything floats, nothing seems important.

Elevation in Android: Properties and API

In Android, elevation is implemented as a built-in View property since API 21 (Android 5.0 Lollipop). View.elevation sets the base height in pixels (px), and View.translationZ provides additional offset for animations (e.g., on press). The total visual height = elevation + translationZ. Both properties support animation via ViewPropertyAnimator or ObjectAnimator.

xml
<!-- XML: elevation and translationZ -->
<Button
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:elevation="4dp"
    android:translationZ="2dp"
    android:stateListAnimator="@anim/button_elevation"
    android:text="Button with elevation" />

StateListAnimator — an XML resource for animating elevation and translationZ based on View state (pressed, focused, enabled). For example, when a button is pressed, elevation can increase from 2 dp to 8 dp, creating a lift effect. StateListAnimator supports animation via ObjectAnimator for any View properties.

kotlin
// Kotlin: programmatic elevation setup
import android.animation.ObjectAnimator
import android.view.View

val myButton: View = findViewById(R.id.myButton)
myButton.elevation = 4f  // base height in px

// Elevation animation on press
val animator = ObjectAnimator.ofFloat(
    myButton,
    "translationZ",
    0f,
    8f
).apply {
    duration = 150
    repeatMode = ValueAnimator.REVERSE
    repeatCount = 1
}

OutlineProvider — a key component for correct elevation shadow rendering. By default, Android uses ViewOutlineProvider.BACKGROUND, which creates a contour based on the background drawable. For Views with rounded corners (via shape drawable), a custom OutlineProvider must be set, otherwise the shadow will be rectangular. Material components (CardView, MaterialButton) manage OutlineProvider automatically.

Elevation Levels in Material Design 3

Material Design 3 (Material You) revised the elevation system compared to Material Design 2. Instead of 12 fixed levels (Material 2), M3 offers 5 basic tones, each corresponding to a specific elevation level. Additionally, M3 introduces the concept of “color shadow” on Android 12+: the shadow can be tinted with the theme’s accent color instead of being black-and-gray.

LevelElevationUsageShadow (light theme)
Level 00 dpBackgrounds, Surface containersNo shadow
Level 11 dpCards, ListItem, menus0.05 opacity, 2px blur
Level 23 dpSearch bar, Bottom navigation0.08 opacity, 4px blur
Level 36 dpFAB, FloatingActionButton0.11 opacity, 8px blur
Level 48 dpSnackbar, Bottom sheet0.12 opacity, 12px blur
Level 512 dpNavigation drawer, Dialog0.14 opacity, 16px blur
Level 624 dpModal dialog, Popup menu0.15 opacity, 24px blur

Interaction elevation — a temporary increase in elevation during user interaction with an element. In Material Design 3, interactive elements (buttons, cards) gain +1–2 dp to their base elevation when pressed (pressed state) or focused (focused state). For FloatingActionButton, interaction elevation is +6 dp. The transition animation between states should last 150–200 ms for a natural tactile response.

Elevation in Jetpack Compose

Jetpack Compose supports elevation via Card and Surface components, which have a built-in elevation parameter. Unlike the View System, Compose renders shadows through its own render engine, ensuring consistent behavior across all Android versions (API 21+). Modifier.shadow() is a low-level modifier for adding shadows to any composable.

kotlin
// Jetpack Compose: elevation via Surface and Card
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Surface

Card(
    elevation = CardDefaults.cardElevation(
        defaultElevation = 4.dp,
        pressedElevation = 8.dp,
        focusedElevation = 6.dp
    ),
    colors = CardDefaults.cardColors(
        containerColor = MaterialTheme.colorScheme.surface
    )
) {
    Text("Elevation-controlled card")
}

// Modifier.shadow for custom shapes
Surface(
    modifier = Modifier
        .shadow(elevation = 6.dp, shape = RoundedCornerShape(16.dp))
        .clickable { /* action */ },
    shape = RoundedCornerShape(16.dp),
    color = MaterialTheme.colorScheme.surface
) { Text("Surface with shadow") }

Elevation animation in Compose is implemented via animateFloatAsState or Animatable. When elevation changes, Compose automatically animates the shadow. For interactive elements, use M3 InteractionSource in combination with animateElevation so that elevation responds to presses, focus, and drag. Material 3 in Compose 1.2+ supports color shadow — a shadow tinted with the theme’s primary Container color.

Elevation on iOS: Height Simulation

On iOS, there is no built-in analogue of elevation from Material Design. Apple’s Human Interface Guidelines do not use z-coordinates for shadow management — instead, developers configure shadows manually via CALayer.shadow*. However, the concept of visual hierarchy through shadows and depth also exists in iOS: modal presentations, UIAlertController, UIPopoverPresentationController — all use shadows to separate from the background.

To simulate elevation on iOS, developers use a combination of shadowOpacity + shadowRadius + shadowOffset. The higher the required “height,” the larger the blur radius and shadow offset. In SwiftUI, shadows are set via the .shadow() modifier with parameters. For Material-like behavior on iOS, there are libraries such as Material Components for iOS (MDC) by Google.

swift
// iOS: elevation simulation via CALayer
import UIKit

extension UIView {
    func applyElevation(level: Int) {
        let elevationMap: [Int: (CGFloat, CGFloat, CGFloat)] = [
            1: (0.05, 1, 2),
            2: (0.08, 2, 4),
            3: (0.11, 4, 8),
            4: (0.12, 6, 12),
            5: (0.14, 8, 16),
            6: (0.15, 12, 24)
        ]
        let (opacity, offset, radius) = elevationMap[level] ?? (0.08, 2, 4)
        layer.shadowColor = UIColor.black.cgColor
        layer.shadowOpacity = Float(opacity)
        layer.shadowOffset = CGSize(width: 0, height: offset)
        layer.shadowRadius = radius
        layer.shouldRasterize = true
        layer.rasterizationScale = UIScreen.main.scale
    }
}

// Usage
cardView.applyElevation(level: 3)  // equivalent of 6 dp

Material Components for iOS (MDC-iOS) — a Google library that ports Material Design elevation to iOS. MDC-iOS provides the MDCShadowElevation class with predefined values, MDCShadowLayer for shadow rendering, and MDCCard for Material cards with proper elevation. MDC-iOS supports elevation animation on press via stateful shadow properties.

Frequently Asked Questions

What is the difference between elevation and translationZ in Android?

Elevation — the base height of an element in the z-plane (set in XML or code). translationZ — a dynamic offset for animation (e.g., on press). Visual height = elevation + translationZ. elevation is animated via ViewPropertyAnimator, translationZ via ObjectAnimator. Use translationZ for temporary height changes, elevation for permanent ones.

Why did Material Design 3 change the elevation system?

Material Design 3 simplified the elevation system from 12 to 7 levels to reduce cognitive load on designers and developers. Instead of exact values (2 dp, 4 dp, 8 dp), M3 uses tones (Level 0–6) with predefined shadow parameters. On Android 12+, support for color shadows was added, which adapt to the app’s theme.

How does elevation affect Android performance?

Elevation itself does not affect performance because shadows are rendered by hardware (GPU). However, frequent elevation changes (every frame during animation) can cause redrawing of the View and adjacent areas. For animation, use translationZ instead of changing elevation, as translationZ is optimized for frequent changes. For complex screens with 20+ elevated elements, enable view.setLayerType(View.LAYER_TYPE_HARDWARE, null).

How to create elevation shadow without lifting the element?

In Android, elevation always lifts the element above the background and changes the drawing order (z-order). If you need only the shadow without changing the z-order, use cardUseCompatPadding in CardView or custom shadow rendering via Paint.setShadowLayer() in onDraw(). In Jetpack Compose, use Modifier.graphicsLayer { shadowElevation = 4f }.

What is the elevation of standard Android components?

Material Design components have fixed elevation values: FloatingActionButton — 6 dp (12 dp on press), CardView — 1–8 dp (configurable), BottomNavigationView — 8 dp, Toolbar — 4 dp, Snackbar — 6 dp, Dialog — 24 dp. MaterialButton from Material Components Library has an elevation of 2 dp, rising to 8 dp when pressed.

Summary

  • Elevation — z-height of an element in Material Design, measured in dp, determining shadow and drawing order.
  • In Android, elevation is set via the View property starting from API 21, and translationZ is used for animations.
  • OutlineProvider — required for correct shadows on elements with rounded corners.
  • Material Design 3 uses 7 elevation levels: Level 0 (0 dp) — Level 6 (24 dp).
  • Jetpack Compose manages elevation via CardDefaults.cardElevation() and Modifier.shadow().
  • On iOS, elevation is simulated via CALayer.shadow with predefined opacity/offset/radius parameters.
  • Interaction elevation (+1–6 dp) creates tactile feedback when pressing interactive elements.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also