I’ve been trying to reuse the same layout in several resource folders, without success. First I tried following the instructions here: https://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters and adding a resource file like this:
<resources>
<item name="main" type="layout">@layout/main_twopanes</item>
</resources>
I get two LINT warnings. The first is Attribute is missing the Android namespace prefix. If I fix that by adding a xmlns:android="http://schemas.android.com/apk/res/android", then I still get Unexpected text found in layout file: "@layout/layout_file". It will blow up when I try to inflate with these two exceptions:
android.view.InflateException: Binary XML file line #2: Error inflating class resources
Caused by: java.lang.ClassNotFoundException: android.view.resources
I’m using API 15 and the support library. The include/merge trick doesn’t seem to work with fragments, as that also blows up with a different exception.
Has anyone managed to get this to work?
Thanks!
I got it working. My mistake was putting the aliases in the “layout” folders — they should go in the “values” folder. That and renaming the name attribute fixed all of the errors!