请教各位前辈,继承自View的自定义控件如何增加自定义的属性?baidu了一下,需要添加attrs.xml文件,但里面的format中的值写什么?官方DOC有表吗?

解决方案 »

  1.   

    <?xml version="1.0" encoding="utf-8" ?> 
    <resources>
      <declare-styleable name="CwjView">
      <attr name="age" format="integer" /> 
      <attr name="city" format="string" /> 
      <attr name="university" format="string" /> 
      </declare-styleable>
    </resources>http://www.android123.com.cn/androidkaifa/591.html
      

  2.   

    format 暂时找到的有color,integer,float,boolean,reference, string,dimension,enum
    如果还有其他的请添加到此~~~
                     
      

  3.   

    /framework/base/tools/aapt/ResourceTable.cppstatic status_t compileAttribute  这个函数解析的
      

  4.   

    很简单,在eclipse里面用 鼠标指着xml里的属性,就会出现提示, 有的出现 [boolean],有的出现[dimension]等。这个就是format了。