Skip to content

Commit 292ef1d

Browse files
Update the wear preview code
1 parent 9436a8d commit 292ef1d

File tree

1 file changed

+5
-1
lines changed
  • wear/src/main/java/com/example/wear/snippets/m3/tile

1 file changed

+5
-1
lines changed

wear/src/main/java/com/example/wear/snippets/m3/tile/Tile.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.example.wear.snippets.m3.tile
1919
import android.content.Context
2020
import androidx.wear.protolayout.ResourceBuilders.Resources
2121
import androidx.wear.protolayout.TimelineBuilders.Timeline
22+
import androidx.wear.protolayout.material3.MaterialScope
2223
import androidx.wear.protolayout.material3.Typography.BODY_LARGE
2324
import androidx.wear.protolayout.material3.button
2425
import androidx.wear.protolayout.material3.buttonGroup
@@ -124,12 +125,15 @@ class TileBreakpoints : TileService() {
124125
)
125126
}
126127

128+
fun MaterialScope.myAdaptiveLayout() =
129+
primaryLayout(mainSlot = { text("Hello, World".layoutString) })
130+
127131
// [START android_wear_tile_preview]
128132
@Preview(device = WearDevices.LARGE_ROUND)
129133
fun smallPreview(context: Context) = TilePreviewData {
130134
TilePreviewHelper.singleTimelineEntryTileBuilder(
131135
materialScope(context, it.deviceConfiguration) {
132-
primaryLayout(mainSlot = { text("Hello, World".layoutString) })
136+
myAdaptiveLayout() // varies the layout depending on the size of the screen
133137
}
134138
)
135139
.build()

0 commit comments

Comments
 (0)