Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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..?

like image 511
rupps Avatar asked Feb 02 '26 22:02

rupps


1 Answers

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.

like image 183
prettyvoid Avatar answered Feb 04 '26 16:02

prettyvoid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!