Goal Give your screen Lab 1’s look: its colours in one theme, each shape painted by a Modifier chain.
The idea
The theme hands its colours down; the Modifier paints link by link
package com.yourname.notes.ui.theme
import android.app.Activityimport android.os.Buildimport androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.darkColorSchemeimport androidx.compose.material3.dynamicDarkColorSchemeimport androidx.compose.material3.dynamicLightColorSchemeimport androidx.compose.material3.lightColorSchemeimport androidx.compose.runtime.Composableimport androidx.compose.ui.platform.LocalContext
private val DarkColorScheme = darkColorScheme( primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80)
private val LightColorScheme = lightColorScheme( primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40
/* Other default colors to override background = Color(0xFFFFFBFE), surface = Color(0xFFFFFBFE), onPrimary = Color.White, onSecondary = Color.White, onTertiary = Color.White, onBackground = Color(0xFF1C1B1F), onSurface = Color(0xFF1C1B1F), */)
@Composablefun NotesTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, content: @Composable () -> Unit) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) }
darkTheme -> DarkColorScheme else -> LightColorScheme }
MaterialTheme( colorScheme = colorScheme, typography = Typography, content = content )}The template’s Theme.kt, as the wizard wrote it. Step 3.1 replaces it.
dynamicColor: Boolean = true: the template turns dynamic colour on.- On Android 12 and later,
dynamicLightColorSchemebuilds the colours from your wallpaper. That is your Add’s colour. MaterialThemehands those colours to everything inside it:Scaffold, your screen, the button.
NotesTheme { … }hands down its colours
Scaffold { … }
NotesScreen()
Button(…) paints itself with primary- Add The template:
primarycomes from your wallpaper. - Add Your theme, step 3.1:
primary = Brand, Lab 1’s orange.
Each call sits inside the one above it. A composable takes its colours from the theme, unless its code names one.
package com.yourname.notes
import androidx.compose.foundation.Imageimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.borderimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Buttonimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.clipimport androidx.compose.ui.draw.shadowimport androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.SolidColorimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.input.ImeActionimport androidx.compose.ui.text.input.KeyboardCapitalizationimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Previewimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.emimport androidx.compose.ui.unit.spimport com.yourname.notes.ui.theme.Brandimport com.yourname.notes.ui.theme.CardWhiteimport com.yourname.notes.ui.theme.Fieldimport com.yourname.notes.ui.theme.HeaderEndimport com.yourname.notes.ui.theme.Inkimport com.yourname.notes.ui.theme.Lineimport com.yourname.notes.ui.theme.Mutedimport com.yourname.notes.ui.theme.NotesThemeimport com.yourname.notes.ui.theme.OnBrand
@Composablefun NotesScreen(modifier: Modifier = Modifier) { Column(modifier = modifier.fillMaxSize()) { Box { // The header: a gradient with round corners Column( modifier = Modifier .padding(16.dp) .fillMaxWidth() .height(168.dp) .clip(RoundedCornerShape(28.dp)) .background(Brush.linearGradient(listOf(Brand, HeaderEnd))) .padding(start = 16.dp, top = 20.dp) ) { Image( painter = painterResource(R.drawable.ic_notes), contentDescription = "Notes logo", modifier = Modifier.size(36.dp) ) Row(modifier = Modifier.padding(top = 4.dp)) { Text( text = "Notes", color = OnBrand, fontSize = 30.sp, fontWeight = FontWeight.Black, modifier = Modifier.alignByBaseline() ) Text( text = "0", color = Brand, fontSize = 14.sp, fontWeight = FontWeight.Bold, modifier = Modifier .padding(start = 8.dp) .alignByBaseline() .background(CardWhite, RoundedCornerShape(12.dp)) .padding(horizontal = 10.dp, vertical = 2.dp) ) } }
// The composer: a white card that overlaps the header Column( modifier = Modifier .padding(start = 32.dp, top = 136.dp, end = 32.dp) .fillMaxWidth() .shadow(6.dp, RoundedCornerShape(20.dp)) .background(CardWhite) .padding(16.dp) ) { NotesField( value = "", onValueChange = { }, hint = "Title", singleLine = true ) NotesField( value = "", onValueChange = { }, hint = "Write something…", minLines = 3, modifier = Modifier.padding(top = 8.dp) ) Row( modifier = Modifier.padding(top = 8.dp), verticalAlignment = Alignment.CenterVertically ) { Text( text = "0 / 140", color = Muted, fontSize = 12.sp, modifier = Modifier.weight(1f) ) TextButton( onClick = { }, modifier = Modifier.width(88.dp) ) { Text("Clear") } Button( onClick = { }, shape = RoundedCornerShape(12.dp), modifier = Modifier .padding(start = 4.dp) .width(88.dp) ) { Text("Add") } } } }
// The list's title, and its hint on the right Row(modifier = Modifier.padding(start = 32.dp, top = 24.dp, end = 32.dp)) { Text( text = "YOUR NOTES", color = Muted, fontSize = 12.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.1.em, modifier = Modifier.alignByBaseline() ) Text( text = "Tap to open · hold to delete", color = Muted, fontSize = 12.sp, textAlign = TextAlign.End, modifier = Modifier .padding(start = 16.dp) .weight(1f) .alignByBaseline() ) } }}
// Lab 1's style NotesField, as a function: the same look for both text fields@Composablefun NotesField( value: String, onValueChange: (String) -> Unit, hint: String, modifier: Modifier = Modifier, singleLine: Boolean = false, minLines: Int = 1) { BasicTextField( value = value, onValueChange = onValueChange, modifier = modifier .fillMaxWidth() .background(Field, RoundedCornerShape(12.dp)) .border(1.dp, Line, RoundedCornerShape(12.dp)) .padding(horizontal = 14.dp, vertical = 12.dp), textStyle = MaterialTheme.typography.bodyLarge.copy(color = Ink), singleLine = singleLine, minLines = minLines, keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.Sentences, imeAction = if (singleLine) ImeAction.Next else ImeAction.Default ), cursorBrush = SolidColor(Brand), decorationBox = { innerTextField -> Box { if (value.isEmpty()) { Text(text = hint, color = Muted) } innerTextField() } } )}
@Preview(showBackground = true)@Composablefun NotesScreenPreview() { NotesTheme { NotesScreen() }}The header at the end of this part. You type lines 58 and 59 in step 3.3.
padding(16.dp)before any paint: space around the box, a margin.fillMaxWidth()andheight(168.dp): the box’s size.clip(RoundedCornerShape(28.dp)): the corners are cut; what follows paints only inside.background(…): the paint, orange to rose, from the top-left corner.padding(start = 16.dp, top = 20.dp)after the paint: space inside, a padding.
- a margin
- the size
- the corners
- the paint
- Notesa padding
The header, link by link: each call works on what the calls above it made. Swap two links and the result changes.
Read a chain top to bottom: a padding before background is a margin, after it a padding (sheet card 9). No shape drawables: every shape is a chain.
Lab 1 beside it colors.xml, themes.xml, a shape drawable
colors.xml→Color.kt: the same colours, as Kotlin values (brand→Brand).themes.xml→NotesTheme:colorPrimarybecomesprimary = Brand.- The shape drawables → Modifier links:
bg_header.xmlbecomesclip+background.
Lab 1 · themes.xml
<resources> <style name="Theme.Notes" parent="Theme.Material3.Light.NoActionBar"> <item name="android:windowLightStatusBar">true</item> <item name="android:windowBackground">@color/paper</item> <item name="colorPrimary">@color/brand</item> <item name="colorOnPrimary">@color/on_brand</item> <item name="colorControlActivated">@color/brand</item> <item name="colorOutline">@color/muted</item> </style>
<style name="NotesField"> <item name="android:background">@drawable/bg_field</item> <item name="android:paddingStart">14dp</item> <item name="android:paddingEnd">14dp</item> <item name="android:paddingTop">12dp</item> <item name="android:paddingBottom">12dp</item> <item name="android:textColor">@color/ink</item> <item name="android:textColorHint">@color/muted</item> <item name="android:textSize">16sp</item> </style></resources>Lab 1 · bg_header.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="315" android:endColor="@color/header_end" android:startColor="@color/brand" /> <corners android:radius="28dp" /></shape>Part 2 not finished, or a fresh project? Start here about 4 min
The project: your own from Part 2, or a fresh one: Part 0, steps 0.2 to 0.4 (about 10 minutes).
Your package name, for the code of this page:
Without JavaScript, the code says com.yourname.notes: replace yourname by the name you chose.
MainActivity.kt (the tree shows it as MainActivity, with a class icon): open it, in kotlin+java › com.yourname.notes, select all, then paste this file.
kotlin+java › com.yourname.notes › MainActivity.ktReplace the whole filepackage com.yourname.notes
import android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.activity.enableEdgeToEdgeimport androidx.compose.foundation.layout.WindowInsetsimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawingimport androidx.compose.material3.Scaffoldimport androidx.compose.ui.Modifierimport com.yourname.notes.ui.theme.NotesTheme
class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { NotesTheme { Scaffold( modifier = Modifier.fillMaxSize(), // keep the screen out of the status bar, the gesture bar and the keyboard contentWindowInsets = WindowInsets.safeDrawing ) { innerPadding -> NotesScreen(modifier = Modifier.padding(innerPadding)) } } } }}NotesScreen.kt: open it, select all, then paste this file. Missing? Right-click kotlin+java › com.yourname.notes, the one without
(test), then NewKotlin Class/File: typeNotesScreen, click File in the list, then press Enter.kotlin+java › com.yourname.notes › NotesScreen.ktReplace the whole filepackage com.yourname.notes
import androidx.compose.foundation.Imageimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.borderimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.material3.Buttonimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Previewimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.yourname.notes.ui.theme.NotesTheme
@Composablefun NotesScreen(modifier: Modifier = Modifier) { Column(modifier = modifier.fillMaxSize()) { Box { // The header Column( modifier = Modifier .padding(16.dp) .fillMaxWidth() .height(168.dp) .background(Color(0xFFC2410C)) .padding(start = 16.dp, top = 20.dp) ) { Image( painter = painterResource(R.drawable.ic_launcher_foreground), contentDescription = "Notes logo", modifier = Modifier.size(36.dp) ) Row(modifier = Modifier.padding(top = 4.dp)) { Text( text = "Notes", color = Color.White, fontSize = 30.sp, modifier = Modifier.alignByBaseline() ) Text( text = "0", color = Color.White, modifier = Modifier .padding(start = 8.dp) .alignByBaseline() ) } }
// The composer: a white card that overlaps the header Column( modifier = Modifier .padding(start = 32.dp, top = 136.dp, end = 32.dp) .fillMaxWidth() .background(Color.White) .padding(16.dp) ) { BasicTextField( value = "", onValueChange = { }, modifier = Modifier.fillMaxWidth().border(1.dp, Color.LightGray).padding(12.dp) ) BasicTextField( value = "", onValueChange = { }, modifier = Modifier.padding(top = 8.dp).fillMaxWidth().border(1.dp, Color.LightGray).padding(12.dp) ) Row( modifier = Modifier.padding(top = 8.dp), verticalAlignment = Alignment.CenterVertically ) { Text(text = "0 / 140", modifier = Modifier.weight(1f)) TextButton(onClick = { }, modifier = Modifier.width(88.dp)) { Text("Clear") } Button( onClick = { }, modifier = Modifier .padding(start = 4.dp) .width(88.dp) ) { Text("Add") } } } }
// The list's title, and its hint on the right Row(modifier = Modifier.padding(start = 32.dp, top = 24.dp, end = 32.dp)) { Text(text = "YOUR NOTES", modifier = Modifier.alignByBaseline()) Text( text = "Tap to open · hold to delete", textAlign = TextAlign.End, modifier = Modifier .padding(start = 16.dp) .weight(1f) .alignByBaseline() ) } }}
@Preview(showBackground = true)@Composablefun NotesScreenPreview() { NotesTheme { NotesScreen() }}Restarting this part? Also delete res › drawable › ic_notes.xml (right-click it, Delete…, OK). Keep colors.xml as it is: in step 3.1, skip action d if the
paperline is already there. Until 3.1, Add may already be orange, on paper: that is fine.▶. You are ready when the phone shows the skeleton: an orange band, a white card with two grey boxes, Add in your wallpaper’s colour.
- 3.1 the colours and the theme
- 3.2 the fields, the card, the text
- 3.3 the gradient and the logo
Before you start
By the end you can
- say where a composable gets its colours: from the theme, unless its code names one;
- move a palette into
Color.ktand a light theme; - paint a box link by link: corners, a gradient, a border, a shadow.
- Kotlin kotlin+java › com.yourname.notes
- Resources res › values · res › drawable
- Emulator
Step 1 of 3
Give the app Lab 1’s colours in a light theme
Goal Replace the template’s colours with Lab 1’s palette and a theme without dynamic colour.
- Kotlin kotlin+java › com.yourname.notes › ui.theme
- Resources res › values › colors.xml · themes.xml
- Emulator
-
Paste Lab 1’s colours, as Kotlin values.
- In the Project window, open kotlin+java › com.yourname.notes › ui.theme, then double-click Color.kt.
- Click Copy the file on the panel below.
- In
Color.kt, click in the text, press Ctrl+A, then Ctrl+V.Theme.ktturns red: b fixes it.
Project › Android Tool window · leftFull size
- ui.theme › Color.kt: double-click it.
kotlin+java › com.yourname.notes.ui.theme › Color.ktReplace the whole filepackage com.yourname.notes.ui.theme
import androidx.compose.ui.graphics.Color
// Lab 1's colors.xml, in Kotlin: the same names, the same hex valuesval Brand = Color(0xFFC2410C)val OnBrand = Color(0xFFFFFFFF)val HeaderEnd = Color(0xFFE11D48)val Paper = Color(0xFFFFF8F1)val CardWhite = Color(0xFFFFFFFF)val Field = Color(0xFFFBF6F0)val Line = Color(0xFFE7D9CB)val Ink = Color(0xFF1F1A17)val Muted = Color(0xFF6B6159)val ErrorRed = Color(0xFFB91C1C)
val NoteButter = Color(0xFFFFF1C9)val NoteButterLine = Color(0xFFF2D27A)val NoteMint = Color(0xFFD9F5E6)val NoteMintLine = Color(0xFF93D9B4)val NoteLavender = Color(0xFFECE6FF)val NoteLavenderLine = Color(0xFFC6B8FA)val NotePeach = Color(0xFFFFE1D6)val NotePeachLine = Color(0xFFF7B29A)Color(0xFFC2410C):FF(opaque), then Lab 1’sC2410C. -
Paste The theme: light only, no dynamic colour.
- Double-click Theme.kt, in the same ui.theme folder.
- Click Copy the file on the panel below.
- In
Theme.kt, click in the text, press Ctrl+A, then Ctrl+V.
kotlin+java › com.yourname.notes.ui.theme › Theme.ktReplace the whole filepackage com.yourname.notes.ui.theme
import androidx.compose.material3.MaterialThemeimport androidx.compose.material3.lightColorSchemeimport androidx.compose.runtime.Composable
// Lab 1's themes.xml, in Kotlin: light only, and no dynamic colourprivate val NotesColors = lightColorScheme( primary = Brand, onPrimary = OnBrand, background = Paper, surface = Paper, onSurface = Ink, outline = Muted, error = ErrorRed)
@Composablefun NotesTheme(content: @Composable () -> Unit) { MaterialTheme( colorScheme = NotesColors, typography = Typography, content = content )}primary = Brand: the colour of everyButton.content: @Composable () -> Unit: the screen you write between the braces ofNotesTheme { }(sheet card 7). -
Paste The text style, spaced as in Lab 1.
- Double-click Type.kt, in the same folder.
- Click Copy the file on the panel below.
- In
Type.kt, click in the text, press Ctrl+A, then Ctrl+V.
kotlin+java › com.yourname.notes.ui.theme › Type.ktReplace the whole filepackage com.yourname.notes.ui.theme
import androidx.compose.material3.Typographyimport androidx.compose.ui.text.PlatformTextStyleimport androidx.compose.ui.text.TextStyleimport androidx.compose.ui.text.font.FontFamilyimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.unit.sp
// Set of Material typography styles to start withval Typography = Typography( bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp, // Only to match Lab 1's TextView spacing (a little space above and below the letters). // Compose's default is false: this is not a styling technique, just pixel parity with Lab 1. platformStyle = PlatformTextStyle(includeFontPadding = true) ) /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.sp ), labelSmall = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 16.sp, letterSpacing = 0.5.sp ) */) -
Paste The paper colour, in
colors.xml.- Open res › values › colors.xml, then click Copy 1 line on its panel.
- Click at the end of line 9, press Enter, then Ctrl+V.
res › values › colors.xmlAdd the marked lines<?xml version="1.0" encoding="utf-8"?><resources> <color name="purple_200">#FFBB86FC</color> <color name="purple_500">#FF6200EE</color> <color name="purple_700">#FF3700B3</color> <color name="teal_200">#FF03DAC5</color> <color name="teal_700">#FF018786</color> <color name="black">#FF000000</color> <color name="white">#FFFFFFFF</color> <color name="paper">#FFF8F1</color></resources> -
Paste The window behind Compose, painted paper.
- Open res › values › themes.xml, then click Copy the file on its panel.
- In
themes.xml, click in the text, press Ctrl+A, then Ctrl+V.
res › values › themes.xmlReplace the whole file<?xml version="1.0" encoding="utf-8"?><resources>
<style name="Theme.Notes" parent="android:Theme.Material.Light.NoActionBar"> <!-- The window behind Compose, seen while the app starts: paper, as in Lab 1 --> <item name="android:windowBackground">@color/paper</item> </style></resources>The window behind Compose is still XML: you see it while the app starts.
-
The theme, on the phone.
- Click ▶ Run 'app' and watch the start: paper from the first frame.
- Look at Add: orange. The header has not changed: its code names its own colour.

You should see Add in orange, on paper. The fields and the header wait for 3.2 and 3.3.
Done I see Add in orange, on paper.
Stuck? 3 symptoms · the files
Unresolved reference 'Brand'., inTheme.ktColor.ktstill holds the template’s colours. Paste it again (action a).error: resource color/paper (aka com.yourname.notes:color/paper) not found.colors.xmlhas nopaperline. Add it (action d).- Add is still in your wallpaper’s colour
Theme.ktstill hasdynamicColor. Paste it again (action b), then ▶.
The Kotlin files and themes.xml are the panels above: Copy the file on each. colors.xml at the end of this step:
<?xml version="1.0" encoding="utf-8"?><resources> <color name="purple_200">#FFBB86FC</color> <color name="purple_500">#FF6200EE</color> <color name="purple_700">#FF3700B3</color> <color name="teal_200">#FF03DAC5</color> <color name="teal_700">#FF018786</color> <color name="black">#FF000000</color> <color name="white">#FFFFFFFF</color> <color name="paper">#FFF8F1</color></resources>Step 2 of 3
Dress the fields, the card and the text
Goal Paste the dressed screen: Lab 1’s field style as a function, the card’s shadow, the text sizes, the pill.
- Kotlin NotesScreen.kt · Split
- Emulator
-
Paste The dressed screen: the whole
NotesScreen.kt.- Click the NotesScreen.kt tab, or double-click it in kotlin+java › com.yourname.notes.
- Click Copy the file on the panel below.
- In
NotesScreen.kt, click in the code, press Ctrl+A, then Ctrl+V. - Three imports stay grey, unused:
clip,Brush,HeaderEnd. Step 3.3 uses them.
kotlin+java › com.yourname.notes › NotesScreen.ktReplace the whole filepackage com.yourname.notes
import androidx.compose.foundation.Imageimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.borderimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Buttonimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.clipimport androidx.compose.ui.draw.shadowimport androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.SolidColorimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.input.ImeActionimport androidx.compose.ui.text.input.KeyboardCapitalizationimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Previewimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.emimport androidx.compose.ui.unit.spimport com.yourname.notes.ui.theme.Brandimport com.yourname.notes.ui.theme.CardWhiteimport com.yourname.notes.ui.theme.Fieldimport com.yourname.notes.ui.theme.HeaderEndimport com.yourname.notes.ui.theme.Inkimport com.yourname.notes.ui.theme.Lineimport com.yourname.notes.ui.theme.Mutedimport com.yourname.notes.ui.theme.NotesThemeimport com.yourname.notes.ui.theme.OnBrand
@Composablefun NotesScreen(modifier: Modifier = Modifier) { Column(modifier = modifier.fillMaxSize()) { Box { // The header Column( modifier = Modifier .padding(16.dp) .fillMaxWidth() .height(168.dp) .background(Brand) .padding(start = 16.dp, top = 20.dp) ) { Image( painter = painterResource(R.drawable.ic_launcher_foreground), contentDescription = "Notes logo", modifier = Modifier.size(36.dp) ) Row(modifier = Modifier.padding(top = 4.dp)) { Text( text = "Notes", color = OnBrand, fontSize = 30.sp, fontWeight = FontWeight.Black, modifier = Modifier.alignByBaseline() ) Text( text = "0", color = Brand, fontSize = 14.sp, fontWeight = FontWeight.Bold, modifier = Modifier .padding(start = 8.dp) .alignByBaseline() .background(CardWhite, RoundedCornerShape(12.dp)) .padding(horizontal = 10.dp, vertical = 2.dp) ) } }
// The composer: a white card that overlaps the header Column( modifier = Modifier .padding(start = 32.dp, top = 136.dp, end = 32.dp) .fillMaxWidth() .shadow(6.dp, RoundedCornerShape(20.dp)) .background(CardWhite) .padding(16.dp) ) { NotesField( value = "", onValueChange = { }, hint = "Title", singleLine = true ) NotesField( value = "", onValueChange = { }, hint = "Write something…", minLines = 3, modifier = Modifier.padding(top = 8.dp) ) Row( modifier = Modifier.padding(top = 8.dp), verticalAlignment = Alignment.CenterVertically ) { Text( text = "0 / 140", color = Muted, fontSize = 12.sp, modifier = Modifier.weight(1f) ) TextButton( onClick = { }, modifier = Modifier.width(88.dp) ) { Text("Clear") } Button( onClick = { }, shape = RoundedCornerShape(12.dp), modifier = Modifier .padding(start = 4.dp) .width(88.dp) ) { Text("Add") } } } }
// The list's title, and its hint on the right Row(modifier = Modifier.padding(start = 32.dp, top = 24.dp, end = 32.dp)) { Text( text = "YOUR NOTES", color = Muted, fontSize = 12.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.1.em, modifier = Modifier.alignByBaseline() ) Text( text = "Tap to open · hold to delete", color = Muted, fontSize = 12.sp, textAlign = TextAlign.End, modifier = Modifier .padding(start = 16.dp) .weight(1f) .alignByBaseline() ) } }}
// Lab 1's style NotesField, as a function: the same look for both text fields@Composablefun NotesField( value: String, onValueChange: (String) -> Unit, hint: String, modifier: Modifier = Modifier, singleLine: Boolean = false, minLines: Int = 1) { BasicTextField( value = value, onValueChange = onValueChange, modifier = modifier .fillMaxWidth() .background(Field, RoundedCornerShape(12.dp)) .border(1.dp, Line, RoundedCornerShape(12.dp)) .padding(horizontal = 14.dp, vertical = 12.dp), textStyle = MaterialTheme.typography.bodyLarge.copy(color = Ink), singleLine = singleLine, minLines = minLines, keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.Sentences, imeAction = if (singleLine) ImeAction.Next else ImeAction.Default ), cursorBrush = SolidColor(Brand), decorationBox = { innerTextField -> Box { if (value.isEmpty()) { Text(text = hint, color = Muted) } innerTextField() } } )}
@Preview(showBackground = true)@Composablefun NotesScreenPreview() { NotesTheme { NotesScreen() }}Same layout as Part 2, dressed. b reads what is new.
-
What is new, line by line.
kotlin+java › com.yourname.notes › NotesScreen.ktRead onlypackage com.yourname.notes
import androidx.compose.foundation.Imageimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.borderimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Buttonimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.clipimport androidx.compose.ui.draw.shadowimport androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.SolidColorimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.input.ImeActionimport androidx.compose.ui.text.input.KeyboardCapitalizationimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Previewimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.emimport androidx.compose.ui.unit.spimport com.yourname.notes.ui.theme.Brandimport com.yourname.notes.ui.theme.CardWhiteimport com.yourname.notes.ui.theme.Fieldimport com.yourname.notes.ui.theme.HeaderEndimport com.yourname.notes.ui.theme.Inkimport com.yourname.notes.ui.theme.Lineimport com.yourname.notes.ui.theme.Mutedimport com.yourname.notes.ui.theme.NotesThemeimport com.yourname.notes.ui.theme.OnBrand
@Composablefun NotesScreen(modifier: Modifier = Modifier) { Column(modifier = modifier.fillMaxSize()) { Box { // The header Column( modifier = Modifier .padding(16.dp) .fillMaxWidth() .height(168.dp) .background(Brand) .padding(start = 16.dp, top = 20.dp) ) { Image( painter = painterResource(R.drawable.ic_launcher_foreground), contentDescription = "Notes logo", modifier = Modifier.size(36.dp) ) Row(modifier = Modifier.padding(top = 4.dp)) { Text( text = "Notes", color = OnBrand, fontSize = 30.sp, fontWeight = FontWeight.Black, modifier = Modifier.alignByBaseline() ) Text( text = "0", color = Brand, fontSize = 14.sp, fontWeight = FontWeight.Bold, modifier = Modifier .padding(start = 8.dp) .alignByBaseline() .background(CardWhite, RoundedCornerShape(12.dp)) .padding(horizontal = 10.dp, vertical = 2.dp) ) } }
// The composer: a white card that overlaps the header Column( modifier = Modifier .padding(start = 32.dp, top = 136.dp, end = 32.dp) .fillMaxWidth() .shadow(6.dp, RoundedCornerShape(20.dp)) .background(CardWhite) .padding(16.dp) ) { NotesField( value = "", onValueChange = { }, hint = "Title", singleLine = true ) NotesField( value = "", onValueChange = { }, hint = "Write something…", minLines = 3, modifier = Modifier.padding(top = 8.dp) ) Row( modifier = Modifier.padding(top = 8.dp), verticalAlignment = Alignment.CenterVertically ) { Text( text = "0 / 140", color = Muted, fontSize = 12.sp, modifier = Modifier.weight(1f) ) TextButton( onClick = { }, modifier = Modifier.width(88.dp) ) { Text("Clear") } Button( onClick = { }, shape = RoundedCornerShape(12.dp), modifier = Modifier .padding(start = 4.dp) .width(88.dp) ) { Text("Add") } } } }
// The list's title, and its hint on the right Row(modifier = Modifier.padding(start = 32.dp, top = 24.dp, end = 32.dp)) { Text( text = "YOUR NOTES", color = Muted, fontSize = 12.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.1.em, modifier = Modifier.alignByBaseline() ) Text( text = "Tap to open · hold to delete", color = Muted, fontSize = 12.sp, textAlign = TextAlign.End, modifier = Modifier .padding(start = 16.dp) .weight(1f) .alignByBaseline() ) } }}
// Lab 1's style NotesField, as a function: the same look for both text fields@Composablefun NotesField( value: String, onValueChange: (String) -> Unit, hint: String, modifier: Modifier = Modifier, singleLine: Boolean = false, minLines: Int = 1) { BasicTextField( value = value, onValueChange = onValueChange, modifier = modifier .fillMaxWidth() .background(Field, RoundedCornerShape(12.dp)) .border(1.dp, Line, RoundedCornerShape(12.dp)) .padding(horizontal = 14.dp, vertical = 12.dp), textStyle = MaterialTheme.typography.bodyLarge.copy(color = Ink), singleLine = singleLine, minLines = minLines, keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.Sentences, imeAction = if (singleLine) ImeAction.Next else ImeAction.Default ), cursorBrush = SolidColor(Brand), decorationBox = { innerTextField -> Box { if (value.isEmpty()) { Text(text = hint, color = Muted) } innerTextField() } } )}
@Preview(showBackground = true)@Composablefun NotesScreenPreview() { NotesTheme { NotesScreen() }}- The pill:
background, thenpadding: the space is inside the white, around the count. shadow(6.dp, …): Lab 1’s elevation 6, with the card’s 20 dp corners.NotesField, Lab 1’s field style as a function.(String) -> Unit: a parameter that is a function; it receives the new text. Part 5 uses it..copy(color = Ink): the theme’s text style, with one change, the colour.decorationBox: the hint while the field is empty, theninnerTextField(), the text itself.
- The pill:
-
The dressed screen, in the preview and on the phone.
- Click Split, at the top right of the editor: NotesScreenPreview appears.
- A banner says a build is needed? Click Build & Refresh.
- Click ▶ Run 'app'.
Split previewFull size

You should see Rounded fields with their hints, the card’s shadow, the pill 0. The header is still flat, with the robot.
Done I see Title and Write something… in rounded fields, and the pill 0.
Stuck? 3 symptoms · the file
Unresolved reference 'Brand'., then'CardWhite','Field'…, inNotesScreen.ktStep 3.1’sColor.ktis missing. Do step 3.1 first.- A successful build is needed before the preview can be displayed The preview needs one build. Click Build & Refresh.
- The fields are still grey boxes The paste went into another file. Click the NotesScreen.kt tab, then paste again.
The file at the end of this step is the panel of action a: Copy the file.
Step 3 of 3
Paint the header with a gradient, then add the logo
Goal Type the header’s two paint links and switch to Lab 1’s logo: your screen then matches Lab 1’s.
- Resources res › drawable › ic_notes.xml
- Kotlin NotesScreen.kt · Split
- Emulator
-
A new file for Lab 1’s logo:
ic_notes.xml, in res › drawable.- In the Project window, right-click res › drawable, then choose NewDrawable Resource File.
- A New Resource File window opens: in File name, type
ic_notes, then click OK. ic_notes.xmlopens in Design: click Code.
-
Paste The logo: Lab 1’s white sticky note.
- Click Copy the file on the panel below.
- Click in its text, press Ctrl+A, then Ctrl+V.
res › drawable › ic_notes.xmlNew file<!-- ~ Copyright (C) 2026 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> <path android:fillColor="@android:color/white" android:pathData="M19,3H4.99C3.89,3 3,3.9 3,5l0.01,14c0,1.1 0.89,2 1.99,2h10l6,-6V5C21,3.9 20.1,3 19,3zM7,8h10v2H7V8zM12,14H7v-2h5V14zM14,19.5V14h5.5L14,19.5z"/> </vector>Lab 1’s file, as Asset Studio wrote it.
-
Type The header’s paint: round corners, then a gradient, then the logo.
- Click the NotesScreen.kt tab. At the end of line 52,
// The header, type: a gradient with round corners. - Click at the end of line 57,
.height(168.dp), press Enter, then type.clip(RoundedCornerShape(28.dp)). - On line 59, double-click
Brandin.background(Brand), then typeBrush.linearGradient(.listOf(Brand, HeaderEnd)) - On line 63, double-click
ic_launcher_foreground, then typeic_notes. - A list opens while you type? Press Esc. Android Studio adds each closing bracket: type it anyway, it steps over.
kotlin+java › com.yourname.notes › NotesScreen.ktEdit the marked linesdelete the linetype the linetop to bottom: the line numbers are then Android Studio’s
package com.yourname.notes
import androidx.compose.foundation.Imageimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.borderimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Buttonimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.clipimport androidx.compose.ui.draw.shadowimport androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.SolidColorimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.input.ImeActionimport androidx.compose.ui.text.input.KeyboardCapitalizationimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Previewimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.emimport androidx.compose.ui.unit.spimport com.yourname.notes.ui.theme.Brandimport com.yourname.notes.ui.theme.CardWhiteimport com.yourname.notes.ui.theme.Fieldimport com.yourname.notes.ui.theme.HeaderEndimport com.yourname.notes.ui.theme.Inkimport com.yourname.notes.ui.theme.Lineimport com.yourname.notes.ui.theme.Mutedimport com.yourname.notes.ui.theme.NotesThemeimport com.yourname.notes.ui.theme.OnBrand
@Composablefun NotesScreen(modifier: Modifier = Modifier) { Column(modifier = modifier.fillMaxSize()) { Box { // The header // The header: a gradient with round corners Column( modifier = Modifier .padding(16.dp) .fillMaxWidth() .height(168.dp) .background(Brand) .clip(RoundedCornerShape(28.dp)) .background(Brush.linearGradient(listOf(Brand, HeaderEnd))) .padding(start = 16.dp, top = 20.dp) ) { Image( painter = painterResource(R.drawable.ic_launcher_foreground), painter = painterResource(R.drawable.ic_notes), contentDescription = "Notes logo", modifier = Modifier.size(36.dp) ) Row(modifier = Modifier.padding(top = 4.dp)) { Text( text = "Notes", color = OnBrand, fontSize = 30.sp, fontWeight = FontWeight.Black, modifier = Modifier.alignByBaseline() ) Text( text = "0", color = Brand, fontSize = 14.sp, fontWeight = FontWeight.Bold, modifier = Modifier .padding(start = 8.dp) .alignByBaseline() .background(CardWhite, RoundedCornerShape(12.dp)) .padding(horizontal = 10.dp, vertical = 2.dp) ) } }
// The composer: a white card that overlaps the header Column( modifier = Modifier .padding(start = 32.dp, top = 136.dp, end = 32.dp) .fillMaxWidth() .shadow(6.dp, RoundedCornerShape(20.dp)) .background(CardWhite) .padding(16.dp) ) { NotesField( value = "", onValueChange = { }, hint = "Title", singleLine = true ) NotesField( value = "", onValueChange = { }, hint = "Write something…", minLines = 3, modifier = Modifier.padding(top = 8.dp) ) Row( modifier = Modifier.padding(top = 8.dp), verticalAlignment = Alignment.CenterVertically ) { Text( text = "0 / 140", color = Muted, fontSize = 12.sp, modifier = Modifier.weight(1f) ) TextButton( onClick = { }, modifier = Modifier.width(88.dp) ) { Text("Clear") } Button( onClick = { }, shape = RoundedCornerShape(12.dp), modifier = Modifier .padding(start = 4.dp) .width(88.dp) ) { Text("Add") } } } }
// The list's title, and its hint on the right Row(modifier = Modifier.padding(start = 32.dp, top = 24.dp, end = 32.dp)) { Text( text = "YOUR NOTES", color = Muted, fontSize = 12.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.1.em, modifier = Modifier.alignByBaseline() ) Text( text = "Tap to open · hold to delete", color = Muted, fontSize = 12.sp, textAlign = TextAlign.End, modifier = Modifier .padding(start = 16.dp) .weight(1f) .alignByBaseline() ) } }}
// Lab 1's style NotesField, as a function: the same look for both text fields@Composablefun NotesField( value: String, onValueChange: (String) -> Unit, hint: String, modifier: Modifier = Modifier, singleLine: Boolean = false, minLines: Int = 1) { BasicTextField( value = value, onValueChange = onValueChange, modifier = modifier .fillMaxWidth() .background(Field, RoundedCornerShape(12.dp)) .border(1.dp, Line, RoundedCornerShape(12.dp)) .padding(horizontal = 14.dp, vertical = 12.dp), textStyle = MaterialTheme.typography.bodyLarge.copy(color = Ink), singleLine = singleLine, minLines = minLines, keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.Sentences, imeAction = if (singleLine) ImeAction.Next else ImeAction.Default ), cursorBrush = SolidColor(Brand), decorationBox = { innerTextField -> Box { if (value.isEmpty()) { Text(text = hint, color = Muted) } innerTextField() } } )}
@Preview(showBackground = true)@Composablefun NotesScreenPreview() { NotesTheme { NotesScreen() }}Lines 25, 27 and 41 import
clip,BrushandHeaderEnd: they came with 3.2’s paste.linearGradientruns from the top-left corner to the bottom-right one, as Lab 1’sangle="315". - Click the NotesScreen.kt tab. At the end of line 52,
-
The finished header, in the preview and on the phone.
- Look at the preview: the header turns orange to rose, with round corners and the logo.
- Click ▶ Run 'app', then compare your phone with Lab 1’s, below.
Split previewFull size


You should see The same screen as Lab 1: the gradient, the logo, the floating card, the pill 0.
Done I see the gradient header with the white logo, as in Lab 1.
Stuck? 3 symptoms · the file
Unresolved reference 'ic_notes'.ic_notes.xmlis missing from res › drawable, or its name differs. Do actions a and b again.- The corners are square
.clip(…)is missing, or comes after.background(…): the paint is already done. Put it just before. - The gradient runs the other way The list reads
listOf(HeaderEnd, Brand). PutBrandfirst.
Behind? The files at the end of this step
package com.yourname.notes
import androidx.compose.foundation.Imageimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.borderimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.foundation.text.KeyboardOptionsimport androidx.compose.material3.Buttonimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.clipimport androidx.compose.ui.draw.shadowimport androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.SolidColorimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.input.ImeActionimport androidx.compose.ui.text.input.KeyboardCapitalizationimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Previewimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.emimport androidx.compose.ui.unit.spimport com.yourname.notes.ui.theme.Brandimport com.yourname.notes.ui.theme.CardWhiteimport com.yourname.notes.ui.theme.Fieldimport com.yourname.notes.ui.theme.HeaderEndimport com.yourname.notes.ui.theme.Inkimport com.yourname.notes.ui.theme.Lineimport com.yourname.notes.ui.theme.Mutedimport com.yourname.notes.ui.theme.NotesThemeimport com.yourname.notes.ui.theme.OnBrand
@Composablefun NotesScreen(modifier: Modifier = Modifier) { Column(modifier = modifier.fillMaxSize()) { Box { // The header: a gradient with round corners Column( modifier = Modifier .padding(16.dp) .fillMaxWidth() .height(168.dp) .clip(RoundedCornerShape(28.dp)) .background(Brush.linearGradient(listOf(Brand, HeaderEnd))) .padding(start = 16.dp, top = 20.dp) ) { Image( painter = painterResource(R.drawable.ic_notes), contentDescription = "Notes logo", modifier = Modifier.size(36.dp) ) Row(modifier = Modifier.padding(top = 4.dp)) { Text( text = "Notes", color = OnBrand, fontSize = 30.sp, fontWeight = FontWeight.Black, modifier = Modifier.alignByBaseline() ) Text( text = "0", color = Brand, fontSize = 14.sp, fontWeight = FontWeight.Bold, modifier = Modifier .padding(start = 8.dp) .alignByBaseline() .background(CardWhite, RoundedCornerShape(12.dp)) .padding(horizontal = 10.dp, vertical = 2.dp) ) } }
// The composer: a white card that overlaps the header Column( modifier = Modifier .padding(start = 32.dp, top = 136.dp, end = 32.dp) .fillMaxWidth() .shadow(6.dp, RoundedCornerShape(20.dp)) .background(CardWhite) .padding(16.dp) ) { NotesField( value = "", onValueChange = { }, hint = "Title", singleLine = true ) NotesField( value = "", onValueChange = { }, hint = "Write something…", minLines = 3, modifier = Modifier.padding(top = 8.dp) ) Row( modifier = Modifier.padding(top = 8.dp), verticalAlignment = Alignment.CenterVertically ) { Text( text = "0 / 140", color = Muted, fontSize = 12.sp, modifier = Modifier.weight(1f) ) TextButton( onClick = { }, modifier = Modifier.width(88.dp) ) { Text("Clear") } Button( onClick = { }, shape = RoundedCornerShape(12.dp), modifier = Modifier .padding(start = 4.dp) .width(88.dp) ) { Text("Add") } } } }
// The list's title, and its hint on the right Row(modifier = Modifier.padding(start = 32.dp, top = 24.dp, end = 32.dp)) { Text( text = "YOUR NOTES", color = Muted, fontSize = 12.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.1.em, modifier = Modifier.alignByBaseline() ) Text( text = "Tap to open · hold to delete", color = Muted, fontSize = 12.sp, textAlign = TextAlign.End, modifier = Modifier .padding(start = 16.dp) .weight(1f) .alignByBaseline() ) } }}
// Lab 1's style NotesField, as a function: the same look for both text fields@Composablefun NotesField( value: String, onValueChange: (String) -> Unit, hint: String, modifier: Modifier = Modifier, singleLine: Boolean = false, minLines: Int = 1) { BasicTextField( value = value, onValueChange = onValueChange, modifier = modifier .fillMaxWidth() .background(Field, RoundedCornerShape(12.dp)) .border(1.dp, Line, RoundedCornerShape(12.dp)) .padding(horizontal = 14.dp, vertical = 12.dp), textStyle = MaterialTheme.typography.bodyLarge.copy(color = Ink), singleLine = singleLine, minLines = minLines, keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.Sentences, imeAction = if (singleLine) ImeAction.Next else ImeAction.Default ), cursorBrush = SolidColor(Brand), decorationBox = { innerTextField -> Box { if (value.isEmpty()) { Text(text = hint, color = Muted) } innerTextField() } } )}
@Preview(showBackground = true)@Composablefun NotesScreenPreview() { NotesTheme { NotesScreen() }}If it doesn’t work
- White icons at the top, hard to see on paper The phone is in dark mode; this theme is light only. Part 7 adds these lines. To fix it now, paste them in
MainActivity.kt, import first. A laterMainActivity.ktfrom a catch-up box or a Stuck? fold drops them again.kotlin+java › com.yourname.notes › MainActivity.ktAdd the marked linespackage com.yourname.notes
import android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.activity.enableEdgeToEdgeimport androidx.compose.foundation.layout.WindowInsetsimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawingimport androidx.compose.material3.Scaffoldimport androidx.compose.ui.Modifierimport androidx.core.view.WindowCompatimport com.yourname.notes.ui.theme.NotesTheme
class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() // Dark icons on the paper, even when the phone is in dark mode (Lab 1's windowLightStatusBar) val bars = WindowCompat.getInsetsController(window, window.decorView) bars.isAppearanceLightStatusBars = true bars.isAppearanceLightNavigationBars = true setContent { NotesTheme { Scaffold( modifier = Modifier.fillMaxSize(), // keep the screen out of the status bar, the gesture bar and the keyboard contentWindowInsets = WindowInsets.safeDrawing ) { innerPadding -> NotesScreen(modifier = Modifier.padding(innerPadding)) } } } }} - Red names right after a paste The paste went into another file. Each panel’s bar names its file: open that one, select all, paste again.
- A colour changed in
Color.ktbut not on the phone The composable names another colour, or Android Studio still shows the old run. Click ▶ again.
Now you If you have time
Your own palette, in two lines
In Color.kt, change the values of Brand (line 6) and HeaderEnd (line 8) to a palette below, then ▶. What follows?
| Palette | Brand | HeaderEnd | |
|---|---|---|---|
| 1 | Ocean | 0xFF0369A1 | 0xFF4F46E5 |
| 2 | Forest | 0xFF047857 | 0xFF0E7490 |
| 3 | Berry | 0xFFBE185D | 0xFF7C3AED |
| 4 | Sunset, the page’s | 0xFFC2410C | 0xFFE11D48 |
See the answer
For Ocean: val Brand = Color(0xFF0369A1) and val HeaderEnd = Color(0xFF4F46E5). The header, Add, Clear, the cursor and the count follow: they read Brand by name or through the theme. Then type Sunset back: the next parts’ captures use it.
Go deeper Texts in strings.xml, as in Lab 1
Compose reads Lab 1’s strings too: Text(stringResource(R.string.add)). This lab keeps English literals, so one set of captures serves both languages.
End of the part
Recap
Your wallpaper chose Add’s colour: the template’s theme had dynamic colour on. Now NotesTheme hands Lab 1’s palette to everything inside it, and each shape is a Modifier chain, read top to bottom.
- say where a composable gets its colours: from the theme, unless its code names one;
- move a palette into
Color.ktand a light theme; - paint a box link by link: corners, a gradient, a border, a shadow.

