-
public final class AppCompatTheme
-
-
Method Summary
Modifier and Type Method Description final static UnitAppCompatTheme(Context context, Boolean readColors, Boolean readTypography, Shapes shapes, Function0<Unit> content)This function creates the components of a MaterialTheme, synthesizing a material theme from values in the context's Theme.AppCompattheme.final static ThemeParameterscreateAppCompatTheme(Context $self, Boolean readColors, Boolean readTypography)This function creates the components of a androidx.compose.material.MaterialTheme, reading the values from the Theme.AppCompatAndroid theme.-
-
Method Detail
-
AppCompatTheme
final static Unit AppCompatTheme(Context context, Boolean readColors, Boolean readTypography, Shapes shapes, Function0<Unit> content)
This function creates the components of a MaterialTheme, synthesizing a material theme from values in the context's
Theme.AppCompattheme.If you are using Material Design Components in your app, you should use the MDC Compose Theme Adapter instead, as it allows much finer-grained reading of your theme.
Synthesizing a material theme from an
AppCompattheme is not perfect, sinceTheme.AppCompatdoes not expose the same level of customization asTheme.MaterialComponents. Going through the pillars of material theming:AppCompat has a limited set of top-level color attributes, which means that AppCompatTheme has to generate/select alternative colors in certain situations. The mapping is currently:
Where the table says "calculated black/white", this means either black/white, depending on which provides the greatest contrast against the corresponding background color.
AppCompat does not provide any semantic text appearances (such as headline6, body1, etc), and instead relies on text appearances for specific widgets or use cases. As such, the only thing we read from an AppCompat theme is the default
app:fontFamilyorandroid:fontFamily. For example:<style name="Theme.MyApp" parent="Theme.AppCompat"> <item name="fontFamily">@font/my_font</item> </style>Compose does not currently support downloadable fonts, so any font referenced from the theme should from your resources. See here for more information.
AppCompat has no concept of shape theming, therefore we use the default value from MaterialTheme.shapes. If you wish to provide custom values, use the shapes parameter.
- Parameters:
context- The context to read the theme from.readColors- whether the read the color palette from the context's theme.readTypography- whether to read the font family from context's theme.shapes- A set of shapes to be used by the components in this hierarchy.
-
createAppCompatTheme
final static ThemeParameters createAppCompatTheme(Context $self, Boolean readColors, Boolean readTypography)
This function creates the components of a androidx.compose.material.MaterialTheme, reading the values from the
Theme.AppCompatAndroid theme. Please see the documentation of AppCompatTheme for more information on how the theme is read.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:
readColors- whether the read the color palette from this context's theme.readTypography- whether to read the font family from this context's theme.
-
-
-
-