-
public final class MdcTheme
-
-
Method Summary
Modifier and Type Method Description final static UnitMdcTheme(Context context, Boolean readColors, Boolean readTypography, Boolean readShapes, Boolean setTextColors, Boolean setDefaultFontFamily, Function0<Unit> content)A MaterialTheme which reads the corresponding values from a Material Components for Android theme in the given context. final static ThemeParameterscreateMdcTheme(Context context, LayoutDirection layoutDirection, Density density, Boolean readColors, Boolean readTypography, Boolean readShapes, Boolean setTextColors, Boolean setDefaultFontFamily)This function creates the components of a androidx.compose.material.MaterialTheme, reading the values from an Material Components for Android theme. -
-
Method Detail
-
MdcTheme
final static Unit MdcTheme(Context context, Boolean readColors, Boolean readTypography, Boolean readShapes, Boolean setTextColors, Boolean setDefaultFontFamily, Function0<Unit> content)
A MaterialTheme which reads the corresponding values from a Material Components for Android theme in the given context.
By default the text colors from any associated
TextAppearances from the theme are not read. This is because setting a fixed color in the resulting TextStyle breaks the usage of androidx.compose.material.ContentAlpha through androidx.compose.material.LocalContentAlpha. You can customize this through the setTextColors parameter.For Shapes, the configuration layout direction is taken into account when reading corner sizes of
ShapeAppearances from the theme. For example, Shapes.medium.topStart will be read fromcornerSizeTopLeftfor View.LAYOUT_DIRECTION_LTR andcornerSizeTopRightfor View.LAYOUT_DIRECTION_RTL.- Parameters:
context- The context to read the theme from.readColors- whether the read the MDC color palette from the context's theme.readTypography- whether the read the MDC text appearances from context's theme.readShapes- whether the read the MDC shape appearances from the context's theme.setTextColors- whether to read the colors from theTextAppearances associated from the theme.setDefaultFontFamily- whether to read and prioritize thefontFamilyattributes from context's theme, over any specified in the MDC text appearances.
-
createMdcTheme
final static ThemeParameters createMdcTheme(Context context, LayoutDirection layoutDirection, Density density, Boolean readColors, Boolean readTypography, Boolean readShapes, Boolean setTextColors, Boolean setDefaultFontFamily)
This function creates the components of a androidx.compose.material.MaterialTheme, reading the values from an Material Components for Android theme.
By default the text colors from any associated
TextAppearances from the theme are not read. This is because setting a fixed color in the resulting TextStyle breaks the usage of androidx.compose.material.ContentAlpha through androidx.compose.material.LocalContentAlpha. You can customize this through the setTextColors parameter.For Shapes, the layoutDirection is taken into account when reading corner sizes of
ShapeAppearances from the theme. For example, Shapes.medium.topStart will be read fromcornerSizeTopLeftfor LayoutDirection.Ltr andcornerSizeTopRightfor LayoutDirection.Rtl.The individual components of the returned ThemeParameters may be
null, depending on the matching 'read' parameter. For example, if you set readColors tofalse, ThemeParameters.colors will be null.- Parameters:
context- The context to read the theme from.layoutDirection- The layout direction to be used when reading shapes.density- The current density.readColors- whether the read the MDC color palette from the context's theme.readTypography- whether the read the MDC text appearances from context's theme.readShapes- whether the read the MDC shape appearances from the context's theme.setTextColors- whether to read the colors from theTextAppearances associated from the theme.setDefaultFontFamily- whether to read and prioritize thefontFamilyattributes from context's theme, over any specified in the MDC text appearances.
-
-
-
-