Android: library projects and custom resources

I have an application that I now want to share part of the project into a library project so that I can reuse it in several other places. Among the materials that use reuse is a custom view that uses the code from this answer (http://stackoverflow.com/questions/1258275/vertical-rotated-label-in-android) with some changes I made for him, Anyway, removable resources are not working properly. Attr.xml is as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <declare-styleable name="VerticalTextView">
        <attr name="text" format="string" />
        <attr name="textColor" format="color" />
        <attr name="textSize" format="dimension" />
        <attr name="rotateLeft" format="boolean" />
    </declare-styleable>
</resources>

and it is mentioned in the layout file in the library project. I get the following error in Eclipse when trying to compile the main project:

[2010-12-20 23:29:38 - MyApp] C: \ Library \ res \ layout \ main.xml: 124: error: the resource identifier was not found for the 'text' attribute in the com.mydomain package. Mylibrary

I am puzzled. I tried everything I could think of to make it work, and I just didn't find the magic combination. How to make a resource working in style work inside a library project?

+3
source share
2 answers

I lost all attempts to get this job in the library package earlier this month and eventually gave up. To remedy the situation, I simply added the source files as โ€œlinkedโ€ (still external to the project and shared), and this works for me.

+1
source

โ€‹โ€‹ ADT 17: , , http://schemas.android.com/apk/res-auto, , :

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto" ... >
    ...
    <com.foo.bar.VerticalTextView
        custom:textColor="#cafebabe"
        custom:rotateLeft="true"
        ... >
+6

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


All Articles