Android flavors with different base themes

后端 未结 3 980
死守一世寂寞
死守一世寂寞 2021-01-05 22:02

I\'ve an android project with multiple flavors that I\'m working on.

This works fine and I can customize elements of the app such as colors and string resources.

3条回答
  •  日久生厌
    2021-01-05 22:13

    Just FYI in case anyone is looking for an easy way to do this going forward.

    In your manifest, update your theme to something like this...

    android:theme="${appTheme}"
    

    Then in your app.gradle do something like this...

    productFlavors {
        flavorA{
            manifestPlaceholders = [appTheme: "@style/AppThemeA"]
        }
        flavorB{
            manifestPlaceholders = [appTheme: "@style/AppThemeB"]
        }
    }
    

    Then you can use whatever styles you want there and they will tie to the flavor selected.

提交回复
热议问题