WearPreviewDevices

@<Error class: unknown class>
annotation WearPreviewDevices


WearPreviewDevices is a multi-preview annotation for composables with different Wear device shapes and sizes. It supports WearDevices.SMALL_ROUND and WearDevices.LARGE_ROUND.

import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.wear.compose.material.Button
import androidx.wear.compose.material.ButtonDefaults
import androidx.wear.compose.material.Icon
import androidx.wear.compose.material.ToggleButton
import androidx.wear.compose.material.ToggleButtonDefaults

var checked by remember { mutableStateOf(true) }
ToggleButton(
    checked = checked,
    onCheckedChange = { checked = it },
    enabled = true,
) {
    Icon(
        painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
        contentDescription = "airplane",
        modifier =
            Modifier.size(ToggleButtonDefaults.DefaultIconSize)
                .wrapContentSize(align = Alignment.Center),
    )
}

Summary

Public constructors

Public constructors

WearPreviewDevices

WearPreviewDevices()