Skip to content

Instantly share code, notes, and snippets.

@dmitriy-chernysh
Last active May 22, 2023 03:03
Show Gist options
  • Save dmitriy-chernysh/9634e879daad703c90e8c73134431a7e to your computer and use it in GitHub Desktop.
Save dmitriy-chernysh/9634e879daad703c90e8c73134431a7e to your computer and use it in GitHub Desktop.
Material 3 Styles (quick start)
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme.Material.NoActionBar" parent="Theme.Material3.Dark.NoActionBar">
<item name="android:windowBackground">@color/colorWindowGreyBackground</item>
<!-- Primary brand color. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/colorWindowBackground</item>
<item name="colorPrimaryContainer">@color/colorAccent</item>
<item name="colorOnPrimaryContainer">@color/colorPrimaryDark</item>
<item name="colorOnSurface">@color/colorPrimary</item>
<!-- Text -->
<item name="android:textColorPrimary">@color/colorTextPrimary</item>
<item name="android:textColorSecondary">@color/colorTextSecondary</item>
<!-- System bars -->
<item name="android:statusBarColor">@color/colorPrimary</item>
<item name="android:navigationBarColor">@color/colorWindowBackground</item>
<item name="android:windowLightStatusBar" tools:targetApi="M">false</item>
<item name="android:windowLightNavigationBar" tools:targetApi="O_MR1">true</item>
<!-- Dialog styles -->
<item name="materialAlertDialogTheme">@style/AppTheme.Material.AlertDialog</item>
<item name="bottomSheetDialogTheme">@style/AppTheme.Material.BottomSheet</item>
<!-- Widget styles -->
<item name="android:textViewStyle">@style/AppTheme.Material.TextView</item>
<item name="materialButtonStyle">@style/AppTheme.Material.Button</item>
<item name="checkboxStyle">@style/AppTheme.Material.CheckBox</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- TextView common style-->
<style name="AppTheme.Material.TextView" parent="TextAppearance.Material3.BodyLarge">
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="AppTheme.Material.TextView.Small" parent="TextAppearance.Material3.BodySmall" />
<style name="AppTheme.Material.TextView.Secondary">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="AppTheme.Material.TextView.Small.Secondary">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Button common style-->
<style name="AppTheme.Material.Button" parent="Widget.Material3.Button">
<item name="android:minHeight">56dp</item>
<item name="shapeAppearanceOverlay">@style/AppTheme.Material.Button.ShapeAppearance</item>
</style>
<style name="AppTheme.Material.Button.ShapeAppearance" parent="@style/ShapeAppearanceOverlay.Material3.Button">
<item name="cornerSize">8dp</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.Material.CheckBox" parent="Widget.Material3.CompoundButton.CheckBox">
<item name="materialThemeOverlay">@style/ThemeOverlay.Material.CheckBox</item>
</style>
<style name="ThemeOverlay.Material.CheckBox" parent="">
<item name="colorOnSurface">@color/colorWindowGreyBackground</item>
<item name="colorSecondary">@color/colorPrimary</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Alert Dialog Material3 common styles-->
<!-- More about https://m3.material.io/libraries/mdc-android/color-theming -->
<style name="AppTheme.Material.AlertDialog" parent="ThemeOverlay.Material3.MaterialAlertDialog.Centered">
<item name="colorPrimary">@color/colorPrimaryLight</item>
<!-- colorSurface - background color of the dialog container-->
<item name="colorSurface">@color/colorWindowBackground</item>
<item name="alertDialogStyle">@style/AppTheme.Material.AlertDialog.Style</item>
<!-- title text-->
<item name="materialAlertDialogTitleTextStyle">
@style/AppTheme.Material.AlertDialog.Title
</item>
<!-- body text -->
<item name="materialAlertDialogBodyTextStyle">
@style/AppTheme.Material.AlertDialog.Body
</item>
<!-- Buttons -->
<item name="buttonBarPositiveButtonStyle">
@style/AppTheme.Material.AlertDialog.Button
</item>
<item name="buttonBarNegativeButtonStyle">
@style/AppTheme.Material.AlertDialog.Button
</item>
<item name="buttonBarNeutralButtonStyle">
@style/AppTheme.Material.AlertDialog.Button.Neutral
</item>
<item name="android:windowAnimationStyle">
@style/AppTheme.Material.AlertDialog.Animation
</item>
</style>
<style name="AppTheme.Material.AlertDialog.Style" parent="MaterialAlertDialog.Material3">
<item name="shapeAppearance">@style/AppTheme.Material.AlertDialog.ShapeAppearance</item>
<item name="shapeAppearanceOverlay">@null</item>
</style>
<style name="AppTheme.Material.AlertDialog.Title" parent="MaterialAlertDialog.Material3.Title.Text.CenterStacked">
<item name="android:textColor">@color/colorTextPrimary</item>
<item name="android:textStyle">normal</item>
<item name="android:textSize">20sp</item>
<item name="android:textAppearance">?attr/textAppearanceHeadlineLarge</item>
</style>
<style name="AppTheme.Material.AlertDialog.Body" parent="MaterialAlertDialog.Material3.Body.Text">
<item name="android:textColor">@color/colorTextPrimary</item>
<item name="android:textAppearance">?attr/textAppearanceBodyMedium</item>
</style>
<style name="AppTheme.Material.AlertDialog.ShapeAppearance" parent="ShapeAppearance.Material3.MediumComponent">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">16dp</item>
</style>
<style name="AppTheme.Material.AlertDialog.Button" parent="Widget.Material3.Button.TextButton.Dialog">
<item name="android:textColor">@color/colorPrimary</item>
<item name="textAllCaps">true</item>
</style>
<style name="AppTheme.Material.AlertDialog.Button.Neutral" parent="Widget.Material3.Button.TextButton.Dialog.Flush">
<item name="android:textColor">@color/colorPrimary</item>
<item name="textAllCaps">true</item>
</style>
<style name="AppTheme.Material.AlertDialog.Animation">
<item name="android:windowExitAnimation">@anim/anim_alert_dialog_hide</item>
<item name="android:windowEnterAnimation">@anim/anim_alert_dialog_show</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.Material.BottomSheet" parent="ThemeOverlay.Material3.BottomSheetDialog">
<item name="colorPrimary">@color/colorWindowBackground</item>
<!-- colorSurface - background color of the dialog container-->
<item name="colorSurface">@color/colorWindowBackground</item>
<item name="bottomSheetStyle">@style/AppTheme.Material.BottomSheet.Style</item>
</style>
<style name="AppTheme.Material.BottomSheet.Style" parent="Widget.MaterialComponents.BottomSheet">
<item name="shapeAppearanceOverlay">
@style/AppTheme.Material.BottomSheet.ShapeAppearance
</item>
</style>
<style name="AppTheme.Material.BottomSheet.ShapeAppearance" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSizeTopLeft">16dp</item>
<item name="cornerSizeTopRight">16dp</item>
<item name="cornerSizeBottomLeft">0dp</item>
<item name="cornerSizeBottomRight">0dp</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment