Help with a custom View attributes inside a Android Library Project

后端 未结 6 1007
眼角桃花
眼角桃花 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:45

    This solution worked for me:

    https://gist.github.com/1105281

    It doesn't use the TypedArray and requires the view to have the library's project package name hardcoded in it.

    It also does not use the styleable values on the programmatic level. You have to hardcode the attribute strings into the view as well.

    You should however declare those same attribute names styleable for Lint to not show an error when you write the XML part.

    A link to the original post on code.google.com:

    http://code.google.com/p/android/issues/detail?id=9656#c17

    It definitely beats copying the files and changing the namespaces but it still isn't as elegant as should be. Enjoy.

提交回复
热议问题