Help with a custom View attributes inside a Android Library Project

后端 未结 6 1011
眼角桃花
眼角桃花 2020-11-30 21:55

I have a custom PieTimer View in an Android Library Project

package com.mysite.android.library.pietimer;

public class PieTimerView extends View {
...
         


        
6条回答
  •  再見小時候
    2020-11-30 22:42

    After two hours of work with my coworker, we figure out how to make this work :

    Library : com.library

    mywidget.java with a class MyWidget

    attrs.xml :

        
    

    and put your attr.

    Instead of having your layout (main.xml for example) with your widget declared in it, just create a my_widget.xml in the layout folder of your library.

    my_widget.xml :

    
    
    
    

    for including it in your layout, just put

    
    

    App : com.myapp

    You just have to duplicate my_widget.xml here, and change the namespace :

    
    
    
    

    And normally it will work !

提交回复
热议问题