Create a Watch Face Using Tag Expressions
Objective
Learn how to create a watch face that responds based on the date, time, step count, heart rate, and battery level using Tag Expressions in Watch Face Studio.
In this Code Lab, you will create a basic watch face with complications such as step count, heart rate, and battery level. Later, you will improve its functionalities and make it visually dynamic using tag expressions.
Overview
Watch Face Studio is a graphic authoring tool that enables you to create watch faces for Wear OS. It offers a simple and intuitive way to add images and components, and to configure the watch movement without any coding. Watch Face Studio supports watch faces for the Galaxy Watch4 or newer version, and other watch devices that run on the same platform.
Tag expressions are conditions in Watch Face Studio that allows you to customize watch face through dynamic configuration of its movement and data.
Set up your environment
You will need the following:
Start your project
- Create a New Project and input Project Name.
- A blank studio will show upon clicking Ok.
Add analog hands and index
Watch Face Studio allows you to add components like text, image, shape, analog hands, and index in a watch face. For your watch to have the look and feel of an analog watch, add the following components:
- Time > Index
- Time > Analog Hands > Minute
- Time > Analog Hands > Hour
NoteThe index and watch hand images used in this Code Lab are no longer included in the latest version of the Watch Face Studio. However, you can choose a design for the index and watch hands from available images in the resources folder. You can also create and add your own design.
You will see that the hands move automatically and in sync with the device time.
Select all the newly added components and click Group. Rename the group as Group_AnalogTime
.
Use a progress bar for seconds
A component like a progress bar can be used to show how much of the process is completed and how much is left. In this step, you will use it to show how far or close the next minute is. To use a progress bar as seconds:
- Click Add Component and select Progress bar.
- Rename the component to
Seconds
.
- Move
Seconds
behind Group_AnalogTime
.
-
In Properties of Seconds, do the following:
a. Adjust the Dimension (Width and Height) to 395
.
b. Align the component to the center.
c. Drag the Background slider to 0%
.
d. Make sure that the Type is a circular progress bar; otherwise change it.
e. In Range Setting, change Value to 0
and click Tags beside it to open the Tags window.
f. Type in [SEC]
. It means that the value from 0
will increment as the value of the second increases.
g. Set Max value to 59
since it is the maximum value of [SEC]
.
NoteIn this scenario, the progress bar disappears in the canvas as the preview only uses the base value, which is 0. However, the component is still present in Run.
In this step, you will learn how grouping works and affects its components. You will also learn how to format the date and time using tags. To format and position a Digital Clock, you need to:
- Add a Digital Clock > Time twice. Rename them as
Hour
and Minute
, respectively.
- Add a Digital Clock > Date and rename the component as
Date
.
- Put them in one group and rename it as
Group_DigitalTime
.
- Go to the properties of
Hour
and change the Text Appearance to 80
. Do the same for Minute
.
- Adjust the text size of
Date
to 15
.
- Adjust the Y Placements of the individual components to look like the image below. When you change a certain component, it won’t affect other components in the group.
-
Format Hour
to only show the time in hour:
a. Go to its properties and click the Tags button in Text Field.
b. Replace text field value with [HOUR_0_23_Z]
to show the current hour with leading zero.
-
Do the same for Minute
but replace the text field value with [MIN_Z]
to show the current minute in an hour with leading zero.
-
Go to Group_DigitalTime
placement properties and align it horizontally. After that, place it to the left. You will see the components adjusted as a group.
Utilize health features and battery level
Watch Face Studio also allows you to utilize data like step count, heart rate, and battery level. Follow the steps below to show these real-time data using tags on texts or progress bar:
Battery Level
- Add a circular progress bar and rename the component as
Battery Level
.
- Drag the Background slider to
0%
.
- Go to Value properties. Replace the value with
0
and, in Tags, input or choose [BATT_PER]
to use the current battery percentage as the value.
- Add a Circle Complication Slot and rename it as
Battery Icon
. Complications are a set of components that can be handled as one group.
- Set the Type to Fixed and change the Default Provider to Watch battery.
- Select Short text as Complication Type and choose Icon + Text for layout.
- Select and move
Battery Level
and Battery Icon
together to the bottom right.
Heart rate
- Add a circular progress bar and rename the component as
Heart Rate
.
- Drag the Background slider to
0%
.
- Go to Value properties. Replace the value with
0
and, in Tags, input or choose [HR]
to use heart rate as value.
- Set the Max value to
240
since it's the maximum heart rate a person can have.
- Add a Text component and rename it as
Heart Rate Label
.
- In the Text Field, input
Heart Rate
and change the text size to 12
.
- Change the Y Placement to
195
.
- Add another text component and rename it as
Heart Rate Text
.
- In the Text Field, input
[HR]
and change the text size to 30
.
- Group
Heart Rate
, Heart Rate Label
, and Heart Rate Text
together.
- Rename the group as
Group_HeartRate
.
- Move the
Group_HeartRate
placement to the center right.
Step count
- Add a circular progress bar and rename the component as
Step Count
.
- Drag the Background slider to
0%
.
- Go to Value properties. Replace the value with
0
and, in Tags, input or choose [SC_PER]
to use the current percentage to the goal of step count.
- Add a Circle Complication Slot and rename it as
Step Count Text
.
- Set the Type to Fixed and change the Default Provider to Step count.
- Select Short text as Complication Type and choose Text + Title for layout. It will now show "Steps" as Title and step count as Text.
- Place the
Step Count Text
in the center horizontally.
- Select and move
Step Count
and Step Count Text
together to the top right.
Select Group_DigitalTime
, Group_BatteryLevel
, Group_HeartRate
, Group_StepCount
, Battery Icon
, and Step Count Text
. Drag them behind Group_AnalogHands
and Seconds
. By doing this, the analog hands would overlap the components.
Make use of tag expressions
You already have three progress bars that show data of battery level, heart rate, and step count. This time, you will make these features more functional by changing the progress bars' color to red using tag expressions.
Tag expressions are conditions that allow you to change the rotation, placement, behavior, and opacity of a component based on tag values. It can alter your watch face's appearance dynamically as the tag value changes. Tag expressions support different types of operators – arithmetic, relational, logical, and ternary.
For this step, you will apply tag expressions on the color opacity. But first, you will have to:
- Duplicate all the circular progress bars (
Seconds
, Battery Level
, Heart Rate
, and Step Count
).
- Move all the duplicates to a new group called
Group_ColorChange
.
- Make sure that
Group_ColorChange
is behind all other groups.
- Change individual component’s color to
#FFFFFF
or white.
- Duplicate this group and rename it as
Group_Background
. Move it behind Group_ColorChange
.
- Drag the Background slider to
16%
and remove tags in the Value properties of each component of Group_Background
.
- Change
Group_ColorChange
color to #FF001E
or red.
Group_ColorChange
will be used as components underneath when you set the opacity of the main components to 0
using tag expressions.
Group_Background
will serve as gap fillers of each progress bar.
Below are conditions that will trigger the opacity of the main components to become 0 and reveal the duplicated red components:
Change the color of the Battery Level to red if the battery level is equal to or less than 20%
- Go to
Group_BatteryLevel
and select Battery Level
.
- Navigate to Color properties.
- Check if the color opacity value is
100
. This will serve as the base value.
- In Tags, input
[BATT_PER]<=20?-100:0
to subtract 100 from the base value of opacity if the battery level is equal to or less than 20. Otherwise, the base opacity value remains the same.
- In the Run pane, adjust the Device > Watch Battery to
20%
or less, and you will see how the color will change to red.
Change the color of Step Count to red if the goal hasn't been reached yet and the time is already 18:00 (6:00 pm) or beyond
- Go to
Group_StepCount
and select Step Count
.
- Navigate to Color properties.
- Check if the color opacity value is
100
. This will serve as the base value.
- In Tags, input
([SC]<[SC_GOAL])*([HOUR_0_23]>=18)?-100:0
to subtract 100 from the base value of opacity if the step count is less than the goal, and if the value of hour in a day is 18 or beyond. Otherwise, the base opacity value remains the same.
- Play with the time control bar in the Run pane and Health > Steps data to see how the color will change from blue to red.
Change the color of the Heart Rate and Seconds to red if the heart rate is below or above the normal
- Go to
Group_HeartRate
and select Heart Rate
.
- Navigate to Color properties.
- Check if the color opacity value is
100
. This will serve as the base value.
- In Tags, input
([HR]<60)+([HR]>100)?-100:0
to subtract 100 from the base value of opacity if the heart rate is below or above the normal (60-100). Otherwise, it remains the same.
- Do the same for
Seconds
.
- Test it in the Run pane by adjusting the Health > Heart rate to below
60
or above 100
, and you will see how the color will change to red.
Prolong the battery life
Now that you already know what group and tag expressions are, it's about time for you to use both to your advantage. It is observed that the darker a watch face design is, the longer the battery life can be. To help the watch stay powered even when there’s a little battery left, you will need to decrease the opacity of the watch face when the Battery Level
is equal to or less than 10%. To do this, you have to:
- Select and combine all created groups and components, except for
Group AnalogTime
, Battery Icon
, and Step Count Text
, to a new group called Group_WatchFace
.
- Go to
Group_WatchFace
Color properties and change the base opacity value to 20
- In Tags, input
[BATT_PER]<=10?0:80
to add 0 to the base value of opacity if the battery level is equal to or less than 10. Otherwise, it adds 80 to the base value, making the watch face 100% visible.
- Adjust the Device > Watch Battery to
10%
or less, and you will see how most components' opacity decreased.
Choose components for Always-On
Always-On Display is a feature that allows your Galaxy Watch to show the time without checking on it by pressing a button or lifting your hand. In Watch Face Studio, you can choose which group or component to display on the Always-On by following these steps:
- Go to the Always-On tab, to see the same set of components you added and grouped.
- Click the eye icon next to the group name to hide or make it visible.
- Hide
Group_WatchFace
, Battery Icon
, and Step Count Text
.
At this point, your Always-On Display will display a basic analog watch face whenever your watch is in idle mode.
Test the watch face
To test your watch face, you need to:
- Connect a watch device to the same network as your computer.
- In Watch Face Studio, select Project > Run on device.
- Select the connected watch device you want to test with.
- If your device is not detected automatically, click Scan devices to detect your device or enter its IP address manually by clicking the + button.
You're done!
Congratulations! You have successfully achieved the goal of this Code Lab. Now, you can create and design a watch face using tag expressions by yourself! If you're having trouble, you may download this file:
Tag Expression Complete Project (272.71 KB)
To learn more about Watch Face Studio, visit:
developer.samsung.com/watch-face-studio