在android style文件中使用自定义属性

通常在style里写控件属性样式除了规范,最主要的还是为了以后可能修改方便些,平常我们style写的都是系统自带的控件属性,如:

<style name="navigationbar_top_img_style">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_centerInParent">true</item>
    </style>

,但是当我想在style文件里引用自定义控件的自定义属性怎么办?

直接引用自定义控件的包名即可

    <style name="navigationbar_radiogroup_style">
        <item name="com.mobeta.android.dslv.view:drawableSize">@dimen/dp20</item>
    </style>

注意:上面是在主工程的时候要加上包名,但是如果在module或其他类库的话,什么都不用加,直接使用自定义属性名字,如:

   <style name="navigationbar_radiogroup_style">
        <item name="drawableSize">@dimen/dp20</item>
    </style>

猜你喜欢

转载自blog.csdn.net/u014769864/article/details/78583031