1. MaterialTheme
androidx.compose.material
Material Design
kotlin
复制代码
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content,
shapes = Shapes
)
kotlin
复制代码
private val DarkColorScheme = darkColorScheme(
secondary = PurpleGrey80,
tertiary = Pink80,
surface = Blue,
onSurface = Navy,
primary = Navy,
onPrimary = Chartreuse
)
private val LightColorScheme = lightColorScheme(
secondary = PurpleGrey40,
tertiary = Pink40,
surface = Blue,
onSurface = Color.White,
primary = LightBlue,
onPrimary = Navy
/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)
kotlin
复制代码
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
kotlin
复制代码
val Shapes = Shapes(
extraSmall = RoundedCornerShape(12.dp),
small = RoundedCornerShape(12.dp)
)
2. Scaffold
kotlin
复制代码
@Composable
fun Scaffold(
modifier: Modifier = Modifier,
topBar: @Composable () -> Unit = {},
bottomBar: @Composable () -> Unit = {},
snackbarHost: @Composable () -> Unit = {},
floatingActionButton: @Composable () -> Unit = {},
floatingActionButtonPosition: FabPosition = FabPosition.End,
containerColor: Color = MaterialTheme.colorScheme.background,
contentColor: Color = contentColorFor(containerColor),
contentWindowInsets: WindowInsets = ScaffoldDefaults.contentWindowInsets,
content: @Composable (PaddingValues) -> Unit
) {
...
}
3. Surface
4. layouts
Compose 布局基础知识
5. Modifier
Compose 修饰符
Compose 修饰符列表