Custom attribute imported from another Android project

From what I read elsewhere , the "Unknown Resource Identifier" compiler error for user attributes disappears when the namespace for the included project is changed to: xmlns: si = "http://schemas.android.com/apk/ lib / com .my.base.project "instead of" xmlns: si = "http://schemas.android.com/apk/ res /com.my.base.project"

This still does not solve the problem of actually reading the value of the custom attribute. Out of context without a project. The control gets the default value. Any ideas to make this work?

In my application, I use this custom attribute like this in the layout XML file:

<merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:si="http://schemas.android.com/apk/lib/com.my.base.project"> <com.my.base.project.view.CustomView si:collapsedHeight="100dp"> </com.my.base.project.view.CustomView> </merge> 
+4
source share
1 answer

From the release note :

Added support for custom views with custom attributes in libraries. Custom attribute layouts should use the http://schemas.android.com/apk/res-auto namespace URI instead of the URI, which includes the application package name. This URI is replaced by the application defined at build time.

They marked it as “released” using SDK Tools, revision 17 (March 2012).

+11
source

Source: https://habr.com/ru/post/1399813/


All Articles