Android - How to get a second set of resources?

I have an app that needs to be branded for two different clients. Application design, code, usage, and flow are identical. Branding is simply changing the resources of Android to use different colors and fonts for the time being. It is also possible that they will use different drawings and layouts. There are also some resources that are the same for both brands.

Currently, we only have two different projects with duplicate code files, but with different sets of resource files.

Is it possible to have one project with all the resources (shared resources, brand 1 resources and brand 2 resources) and have a compile-time flag to decide which set of resources to use?

Edit: I'm looking for something similar to having different sets of layouts and resources based on screen size and density.

+4
source share
3 answers

Use Android Studio. In Android studio, you will have a flavorfolder inside the project. you can put resources according to taste. Example:

Project-
      flavor-
             demo-
             |   src-
             |      res-
             |         drawable-
             |                ic_launcher.png
             brand1-
             |    src-
             |      res-
             |         drawable-
             |                ic_launcher.png
             brand2-
                 src-
                   res-
                      drawable-
                             ic_launcher.png

and indicate this in your gradle file like this.

 android{
 ....
 productFlavors {
        demo {
            applicationId "com.example.app.demo"
            versionName "1.0.3"
        }
        brand1 {
            applicationId "com.example.app.brand1"
            versionName "1.0"
        }
         brand2 {
                applicationId "com.example.app.brand2"
                versionName "1.4"
            }
    }
 ...}

You have the opportunity to choose the build option on the left side of the android studio. He will choose a resource in accordance with your chosen taste.

Please note: Android Studio is slow. You must have at least 8 GB of memory.

Read this document

+4
source

, . , , , .

+2

Take a look at this . I read it, this could also help you with how to provide alternative resources.

Thanks,

0
source

All Articles