A gradle plugin that generates Material Design 3 theme for Android projects.

Overview

MaterialThemeBuilderPlugin

Same as Google's Material Theme Builder, but as a gradle plugin.

Usage

gradle-plugin

Replace all the below with the version shows here.

  1. Add gradle plugin

    ' } }">
    // "old way"
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'dev.rikka.tools.materialthemebuilder:gradle-plugin:'
        }
    }
    ' }">
    // "new way"
    plugins {
        id 'dev.rikka.tools.materialthemebuilder' version ''
    }
  2. Use the plugin in Android application or library module

    plugins {
        id('dev.rikka.tools.materialthemebuilder')
    }
    
  3. Config

    = 2.0.0 provides such attributes // Enable this if your are using rikka.material:material generatePalette = false // Generate Material Design 3 color tokens attributes (such as palettePrimary100) // When necessary, you can use this if your are not using rikka.material:material generatePaletteAttributes = false // Generate "textColorOnXxx" attributes such as "textColorOnPrimary", "textColorOnPrimaryHighEmphasis" // and "textColorOnPrimaryMediumEmphasis" generateTextColors = false }">
    materialThemeBuilder {
        // List of themes to generate
        themes {
            // Name of the theme
            theme1 {
                // Primary color, acts as the source color
                primaryColor = "#3F51B5"
                
                // Optional colors, override colors calculated from the source color
                //secondaryColor = "#000000"
                //tertiaryColor = "#000000"
                //neutralColor = "#000000"
                
                // Use dynamic colors on API 31+
                dynamicColors = false
                
                lightThemeFormat = "Theme.Material3.Light.%s"
                lightThemeParent = "Theme.Material3.Light.Rikka"
                darkThemeFormat = "Theme.Material3.Dark.%s"
                darkThemeParent = "Theme.Material3.Dark.Rikka"
            }
            theme2 {
                // ...
            }
        }
    
        // List of extended colors
        extendedColors {
            // Name of the color
            example {
                color = "#000000"
                // Harmonize generated color with primary color
                harmonize = true
            }
        }
    
        // Package name of your application, used in generated class
        packageName = "com.example"
    
        // Optional parts:
    
        // Add Material Design 3 color tokens (such as palettePrimary100) in generated theme
        // rikka.material:material >= 2.0.0 provides such attributes
        // Enable this if your are using rikka.material:material
        generatePalette = false
        
        // Generate Material Design 3 color tokens attributes (such as palettePrimary100)
        // When necessary, you can use this if your are not using rikka.material:material
        generatePaletteAttributes = false
        
        // Generate "textColorOnXxx" attributes such as "textColorOnPrimary", "textColorOnPrimaryHighEmphasis"
        // and "textColorOnPrimaryMediumEmphasis"
        generateTextColors = false
    }

    Harmonize color with dynamic themes:

     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
         HarmonizedColors.applyToContextIfAvailable(
             context,
             HarmonizedColorsOptions.Builder()
                 .setColorAttributeToHarmonizeWith(R.attr.colorPrimary)
                 .setColorAttributes(
                     HarmonizedColorAttributes.create(
                         HarmonizedColorAttributes.createMaterialDefaults().attributes
                             .plus(Harmonization.HARMONIZED_COLOR_ATTRIBUTES)
                     )
                 )
             !!.build()
         )
     }
You might also like...
Android Sample Project with Material Design and Toolbar.

AndroidMaterialDesignToolbar -- PROJECT IS NOT SUPPORTED Android Sample Project with Material Design and Toolbar. Project use Appcompat library for ma

Android drawer icon with material design animation
Android drawer icon with material design animation

LDrawer Android drawer icon with material design animation Note Basically same as appcompat_v7 version 21, you can use appcompat_v7 compile 'com.andro

Floating Action Button for Android based on Material Design specification
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

A library support form with material design, construct same with Android UI Framework

SwingUI A slight Java Swing library support form with material design, construct same with Android UI Framework writen in Kotlin Supported: 1. Screen:

Android Material Design Components
Android Material Design Components

Android-Material-Design-Components Material design is a comprehensive guide for visual, motion, and interaction design across platforms and devices. G

Modular and customizable Material Design UI components for Android

Material Components for Android Material Components for Android (MDC-Android) help developers execute Material Design. Developed by a core team of eng

Easy creation and management of toggle buttons on Android from the Material Design spec.
Easy creation and management of toggle buttons on Android from the Material Design spec.

ToggleButtonLayout Easy creation and management of toggle buttons from the Material Design spec. Read more about ToggleButtonLayout in our blog post.

Material Design icons by Google

Material design icons Material design icons is the official icon set from Google. The icons are designed under the material design guidelines. 4.0.0 U

A Material Design ViewPager easy to use library
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

Comments
  • Can't generate text colors

    Can't generate text colors

    I'm using following code for MaterialThemeBuilder:

    materialThemeBuilder {
        themes {
    
            create("Materialmedia") {
                isDynamicColors = true
    
                lightThemeFormat = "ThemeOverlay.Light.%s"
                lightThemeParent = "AppTheme"
                darkThemeFormat = "ThemeOverlay.Dark.%s"
                darkThemeParent = "AppTheme"
            }
        }
    
        packageName = "com.fusoft.media"
        generateTextColors = true
    }
    

    and without generateTextColors everything works fine, but if I add generateTextColors then Im gettting this error: ERROR:C:\Users\hesam\AndroidStudioProjects\media-Material\app\build\generated\materialThemeBuilder\debug\res\color\m3_text_color_on_background.xml:3: AAPT: error: resource dimen/m3_emphasis_disabled (aka com.fusoft.media:dimen/m3_emphasis_disabled) not found. This error is repeated for all text styles (m3_text_color_on_error etc.) and all of this because of m3_emphasis_disabled.

    Same errors with this code:

    materialThemeBuilder {
        themes {
    
            create("Materialmedia") {
                isDynamicColors = true
                generateTextColors = true
    
                lightThemeFormat = "ThemeOverlay.Light.%s"
                lightThemeParent = "AppTheme"
                darkThemeFormat = "ThemeOverlay.Dark.%s"
                darkThemeParent = "AppTheme"
            }
        }
    }
    

    Clean Project & Rebuild doesnt fix this problem

    Stacktrace: https://pastebin.com/uCf86R1p

    opened by thewolfprod 1
Owner
Rikka apps
Rikka apps
Showcase of the new AppCompat 21, which includes new Material Theme, working in pre-21 devices.

MaterialEverywhere (deprecated) This example is deprecated, I recommend taking a look at MaterializeYourApp repository. Showcase of the new AppCompat

Antonio Leiva 1.3k Dec 17, 2022
Material You Theme for Frames Dashboard

Material You Theme for Frames Dashboard Frames Dashboard Copy everything into your Frames project, edit colors, corner radius... Use compileSdk = 31 V

pashapuma 8 Dec 14, 2022
Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library.

Material Design Dimens Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library. Dimens Pattern: R.di

Dmitry Malkovich 1.4k Jan 3, 2023
A library to bring fully animated Material Design components to pre-Lolipop Android.

Material MaterialLibrary is an Open Source Android library that back-port Material Design components to pre-Lolipop Android. MaterialLibrary's origina

Rey Pham 6k Dec 21, 2022
The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.

MaterialDrawer ... the flexible, easy to use, all in one drawer library for your Android project. What's included ?? • Setup ??️ • Migration Guide ??

Mike Penz 11.6k Dec 27, 2022
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Zendesk 6.4k Dec 26, 2022
Implementation of Ripple effect from Material Design for Android API 9+

RippleEffect ExpandableLayout provides an easy way to create a view called header with an expandable view. Both view are external layout to allow a ma

Robin Chutaux 4.9k Dec 30, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Jan 9, 2023
Android drawer icon with material design animation

LDrawer Android drawer icon with material design animation Note Basically same as appcompat_v7 version 21, you can use appcompat_v7 compile 'com.andro

Hasan Keklik 1.4k Dec 25, 2022
[] Android Library that implements Snackbars from Google's Material Design documentation.

DEPRECATED This lib is deprecated in favor of Google's Design Support Library which includes a Snackbar and is no longer being developed. Thanks for a

null 1.5k Dec 16, 2022