Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom attribute imported from another android project

From what I read elsewhere, the compiler error "No resource identifier found" for custom attributes goes away when you change the namespace for an included project 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 doesn't solve the problem of actually reading the custom attribute's value. From a non project context. The control just gets the default value. Any ideas to get this working?

In my application I use this custom attribute like so in a 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>
like image 286
Diederik Avatar asked Dec 21 '22 01:12

Diederik


1 Answers

From the release notes:

Added support for custom views with custom attributes in libraries. Layouts using custom attributes must use the namespace URI http://schemas.android.com/apk/res-auto instead of the URI that includes the app package name. This URI is replaced with the app specific one at build time.

They marked it as "released" with SDK Tools, Revision 17 (March 2012).

like image 184
Diederik Avatar answered Feb 04 '23 23:02

Diederik