rupps
rupps

Reputation: 9887

layout xml in library project and child projects

My app uses a library project "core project" with the application core, then little projects "child projects" for the particularities of each supported device, ie. Amazon Fire TV, Kindle tablets, regular google tablets, phones, etc.

Let's say, I have a Custom View class MyCustomView that inflates programmatically a layout R.layout.layout_customview. Both are on the core project:

public class MyCustomView {
     .
     .
     inflate (R.layout.layout_customview);
     .
     .
}

I'd like to create an alternative layout for this custom view in one of the child projects, so I created the layout_customview.xml and put it into the child project res/layout.

However, the custom view keeps inflating the other one under the core project res/layout (sounds logical after all, as they both reside in the same project).

Is there a way to change this behavior? ie. "override" xml layout files, or do I have to give the alternative layout a different name, extend the class, etc..?

Upvotes: 3

Views: 1463

Answers (1)

prettyvoid
prettyvoid

Reputation: 3686

In cases where a resource ID is defined in both the application and the library, the tools ensure that the resource declared in the application gets priority and that the resource in the library project is not compiled into the application .apk. This gives your application the flexibility to either use or redefine any resource behaviors or values that are defined in any library.

Managing Projects

I guess the better course here is just to duplicate the xml in your projects.

Upvotes: 3

Related Questions