Material Design
Build beautiful, consistent Android UIs with Material Components and Material You
Components
Theming
Material You
Navigation
Material Overview
Material Design is Google's design system for creating intuitive, beautiful interfaces. On Android, the Material Components library provides ready-made widgets — buttons, cards, text fields, navigation — that follow Material 3 guidelines.
Material 3 Stack
────────────────
Design tokens (color, type, shape)
↓
Theme.Material3 (XML) / MaterialTheme (Compose)
↓
Material Components (Button, Card, TextInputLayout, FAB)
↓
Your screens — consistent look & accessible UX
Concept Purpose
Color roles Semantic colors — primary, surface, error — not raw hex everywhere
Typography scale headline, title, body, label — consistent text hierarchy
Shape Corner radius family — rounded cards, buttons, sheets
Motion Shared axis, fade, container transform transitions
Elevation Shadow depth showing component hierarchy
1 Material Components
Add the Material library and use components instead of basic widgets for a polished, accessible UI out of the box.
Gradle dependency
Kotlin — app/build.gradle.kts dependencies {
implementation("com.google.android.material:material:1.12.0")
}
MaterialButton & TextInputLayout
XML — activity_login.xml <com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign In" />
MaterialCardView
XML — item_product.xml <com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardElevation="2dp"
app:cardCornerRadius="12dp">
<LinearLayout
android:padding="16dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:text="Product Name" ... />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
Snackbar
Kotlin Snackbar.make(binding.root, "Item deleted", Snackbar.LENGTH_LONG)
.setAction("Undo") { viewModel.undoDelete() }
.show()
2 Theming
Material themes define color roles, typography, and shapes. Extend Theme.Material3 and reference semantic attributes in layouts.
themes.xml (Material 3)
XML — res/values/themes.xml <style name="Theme.MyApp" parent="Theme.Material3.Light.NoActionBar">
<item name="colorPrimary">@color/md_theme_primary</item>
<item name="colorOnPrimary">@color/md_theme_on_primary</item>
<item name="colorSurface">@color/md_theme_surface</item>
<item name="colorOnSurface">@color/md_theme_on_surface</item>
<item name="colorError">@color/md_theme_error</item>
</style>
Using theme attributes in layouts
XML <TextView
android:textColor="?attr/colorOnSurface"
android:background="?attr/colorSurface"
android:textAppearance="?attr/textAppearanceBodyLarge" />
MaterialToolbar
Kotlin — MainActivity.kt setSupportActionBar(binding.toolbar)
supportActionBar?.apply {
title = "My App"
setDisplayHomeAsUpEnabled(true)
}
3 Material You
Material You (Android 12+) generates personalized color schemes from the user's wallpaper using dynamic color.
Enable dynamic color
Kotlin — MainActivity.kt override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivitiesIfAvailable(this)
super.onCreate(savedInstanceState)
// ...
}
Material Theme Builder
Use Material Theme Builder to generate a complete color scheme, then export colors.xml and themes.xml for light and dark variants.
Tip: Dynamic color works best when your theme uses Material 3 color roles (colorPrimary, colorSecondary, colorTertiary) rather than hard-coded hex values in every layout.
4 Typography & Elevation
Material typography uses a type scale. Elevation creates visual hierarchy through shadows and layering.
Text style Typical use
textAppearanceHeadlineMediumScreen titles
textAppearanceTitleMediumSection headers, list titles
textAppearanceBodyLargePrimary body text
textAppearanceLabelLargeButtons, tabs, chips
FAB with CoordinatorLayout
XML <androidx.coordinatorlayout.widget.CoordinatorLayout ...>
<!-- main content -->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:contentDescription="Add item"
app:srcCompat="@drawable/ic_add" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
5 Navigation Patterns
Material recommends clear navigation for top-level destinations — bottom navigation for mobile, navigation drawer for many sections.
BottomNavigationView
XML — activity_main.xml <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bottom_nav_menu" />
Wire to Navigation Component
Kotlin val navController = findNavController(R.id.nav_host)
binding.bottomNav.setupWithNavController(navController)
6 Hands-On Exercises
1
Migrate an app theme to Theme.Material3 and apply generated color roles from Material Theme Builder.
2
Replace plain Button and EditText with MaterialButton and TextInputLayout .
3
Add a FAB that opens a new screen; use contentDescription for accessibility.
4
Enable dynamic color with DynamicColors.applyToActivitiesIfAvailable on Android 12+.
5
Build a list with MaterialCardView rows and consistent typography scale.
6
Add BottomNavigationView connected to Jetpack Navigation with 3 top-level destinations.
7
Bonus: Compare the same screen in Jetpack Compose Material3 using MaterialTheme and Scaffold.
Material Design MCQ Practice
10 Basic MCQs
10 Advanced MCQs
10 Basic Material Design MCQs
1
Material Design is?
A SQL library
B Google design system for UI/UX
C Network protocol
D Gradle plugin
Explanation: Unified guidelines for layout, motion, color, typography.
2
Material Components library provides?
A GPS only
B Database ORM
C Pre-built Material widgets for Android
D APK signer
Explanation: com.google.android.material:material dependency.
3
Theme.Material3 uses?
A No dark mode
B Hollywood theme
C API 1 only
D Material Design 3 color roles and shapes
Explanation: Material 3 (M3) is current generation with dynamic color.
4
FloatingActionButton (FAB)?
A Primary promoted action circular button
B Banner ad
C SQL query
D Service
Explanation: FAB for main screen action — e.g. compose email.
5
TextInputLayout wraps?
A ImageView
B EditText with Material hint and error
C RecyclerView
D MapView
Explanation: Outlined/filled box styles with floating labels.
6
Snackbar from Material?
A Database
B Full screen ad
C Brief bottom message with optional action
D Permission
Explanation: Snackbar.make(coordinator, text, LENGTH).show()
7
MaterialToolbar replaces?
A Retrofit
B FragmentManager
C Room
D ActionBar/Toolbar with Material styling
Explanation: Set as supportActionBar for app bar navigation.
8
Elevation in Material?
A Shadow depth indicating hierarchy
B GPS altitude
C APK version
D SQL index
Explanation: Higher elevation components appear above others.
9
colorPrimary in theme?
A Text color only
B Brand primary color for app bar etc.
C Error color
D Gradle color
Explanation: Theme attributes reference @color roles.
10
BottomNavigationView?
A Keyboard
B SQL bottom table
C Bottom tab navigation for top-level destinations
D Logcat filter
Explanation: 3-5 primary destinations with icons and labels.
10 Advanced Material Design MCQs
11
Material You dynamic color?
A Fixed purple only
B Wallpaper-derived color scheme Android 12+
C iOS feature
D Deprecated
Explanation: DynamicColors.applyToActivitiesIfAvailable for personalized palette.
12
ShapeAppearanceModel?
A Vector path only
B SQL shape
C Customize corner radius and cuts on Material widgets
D Lint
Explanation: Rounded corners family small/medium/large.
13
MotionMaterial shared axis?
A Gradle
B GPS motion
C Sensor only
D Fragment transition patterns in Material motion
Explanation: MaterialContainerTransform for hero transitions.
14
MaterialCardView?
A Card with stroke, elevation, checked state
B ListView
C Service card
D ADB card
Explanation: Rounded card container for list items and panels.
15
Theme overlay?
A Replace entire app theme always
B Apply partial theme to subtree of views
C Night only ban
D Manifest
Explanation: ThemeOverlay.Material3.Button for localized styling.
16
Ripple drawable in Material?
A Water effect only API
B Network ripple
C Touch feedback animation on clickable views
D ProGuard
Explanation: ?attr/selectableItemBackgroundBorderless for ripples.
17
Material3 color roles?
A Random
B RGB only
C One color
D primary, secondary, tertiary, surface, error containers
Explanation: Semantic roles ensure accessible contrast pairs.
18
Catalog Material Components?
A material-components-android.github.io catalog app
B Play Store only paid
C Does not exist
D Firebase
Explanation: Reference app showing all component variants.
19
Compose Material3?
A XML only forever
B androidx.compose.material3 MaterialTheme
C Deprecated
D Separate from Material
Explanation: MaterialTheme(colorScheme, typography) in Compose.
20
Accessibility in Material?
A Ignored
B Optional always
C Min 48dp touch targets, contrast ratios, content descriptions
D API 34 only
Explanation: Material guidelines include accessible color and touch sizing.
Check All Answers
Click an option to select, then check answers.
Material Design Interview Q&A
15 topic-focused questions for interviews and revision.
1 What is Material Design?easy
Answer: Google's design language — components, motion, theming for consistent beautiful apps.
2 Add Material dependency.easy
Answer: implementation("com.google.android.material:material:1.x.x") and Theme.Material3 parent.
3 Setup MaterialToolbar.easy
Answer: XML MaterialToolbar; setSupportActionBar(toolbar); menu inflate.
4 TextInputLayout example.easy
Answer: TextInputLayout > TextInputEditText with hint, error, counter attributes.
5 FAB with Scaffold.medium
Answer: FloatingActionButton onClick in Scaffold fab parameter — Compose or CoordinatorLayout.
6 Material 3 vs Material 2.medium
Answer: M3: dynamic color, updated components, tonal palettes, expressive shapes.
7 Apply dynamic color.medium
Answer: DynamicColors.applyToActivitiesIfAvailable(this) in Activity onCreate.
8 Bottom nav with Navigation.medium
Answer: BottomNavigationView menu IDs match nav graph destinations; setupWithNavController.
9 Material color roles explained.medium
Answer: primary brand actions; surface backgrounds; onPrimary text on primary; error for mistakes.
10 Snackbar vs Toast Material.easy
Answer: Snackbar Material-styled, action button, Coordinator behavior.
11 Card elevation and stroke.easy
Answer: app:cardElevation, app:strokeColor, app:strokeWidth on MaterialCardView.
12 Dark theme Material.medium
Answer: values-night/themes.xml override color roles; DayNight theme parent.
13 Motion transitions.hard
Answer: MaterialSharedAxis, MaterialFade for fragment transitions in Navigation.
14 Compose Material3 theme.medium
Answer: MaterialTheme { Surface { AppContent() } } with light/dark colorScheme.
15 Material design review checklist.hard
Answer: Consistent typography scale, 8dp grid, accessible contrast, meaningful motion, proper hierarchy.