android / wear-os-samples

Multiple samples showing best practices in app and watch face development on Wear OS.
https://developer.android.com/wear
Apache License 2.0
1.12k stars 572 forks source link

Complication curved text #1055

Open devexus opened 6 months ago

devexus commented 6 months ago

Is it possible to create a complication with curved text? I see an option to accomplish this through custom rendering as mentioned in this thread(https://github.com/android/wear-os-samples/issues/240#issuecomment-1171170572), but I'm not quite sure how to access "shortText" in complicationData.

garanj commented 4 months ago

Hi @devexus, are you wanting to achieve this on an AndroidX watch face? Creating a complication with curved text is simple using the Watch Face Format, if you're using that? See: https://github.com/android/wear-os-samples/tree/main/WatchFaceFormat/Complications

yschimke commented 4 months ago

Maybe something like this for accessing the text?

        val text = when (complicationData) {
            is ShortTextComplicationData -> complicationData.text.getTextAt(resources, instant)
            is LongTextComplicationData -> complicationData.text.getTextAt(resources, instant)
            else -> null
        }