RemoteBasicText
RemoteBasicText with a size, colour and style.
Открыть живое интерактивное демо →
Меняйте параметры, смотрите удалённый документ, который получается, и разницу после каждого изменения.
Что это
Самый простой текст без встроенного оформления — основа, из которой строится более богатый текст.
Подходит для
- Полностью свои стили текста
Код
Исходник примера с импортами androidx.compose.remote. CI компилирует каждый фрагмент кода на сайте против AndroidX.
import androidx.compose.remote.creation.compose.layout.RemoteComposable
import androidx.compose.remote.creation.compose.state.rc
import androidx.compose.remote.creation.compose.state.rs
import androidx.compose.remote.creation.compose.state.rsp
import androidx.compose.remote.creation.compose.text.RemoteFontStyle
import androidx.compose.remote.foundation.text.RemoteBasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
@Composable
@RemoteComposable
fun BasicText(text: String, fontSize: Int, color: Color, italic: Boolean) {
// RemoteBasicText (foundation) is the unstyled text primitive the higher-level texts build on.
RemoteBasicText(
text = text.rs,
color = color.rc,
fontSize = fontSize.rsp,
fontStyle = if (italic) RemoteFontStyle.Italic else RemoteFontStyle.Normal,
)
}
API
foundation.text.RemoteBasicText
void RemoteBasicText(RemoteString text, optional RemoteModifier modifier, optional RemoteColor? color, optional RemoteTextUnit? fontSize, optional RemoteFontStyle? fontStyle, optional RemoteFontWeight? fontWeight, optional RemoteFontFamily? fontFamily, optional RemoteTextAlign? textAlign, optional RemoteTextOverflow overflow, optional int maxLines, optional RemoteFontVariation.Settings? fontVariationSettings, optional RemoteTextStyle style)