android attr.xml 怎么在主工程中设置library项目中背景或者其他一些属性。

怎么在主工程中设置library项目中背景或者其他一些属性值。

attr.xml :自定义属性。

format值参考:    http://huangbo-2020.iteye.com/blog/1477611

1、自定义属性:

<resources>

<attr name="searchViewCloseIcon" format="reference" />

</resources>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:src="?attr/searchViewCloseIcon" />

在theme.xml中:

把这个值设在theme.xml的style中,这样aplication引用这个style时,就会对这个属性赋值。

 <item name="searchViewCloseIcon">@drawable/abs__ic_clear</item>

 在主工程中继承这个style,重新给searchViewCloseIcon赋值。

猜你喜欢

转载自liangoogle.iteye.com/blog/1848464