美文网首页
styles.xml中使用固定id的使用

styles.xml中使用固定id的使用

作者: 树蜂 | 来源:发表于2019-02-09 17:35 被阅读0次

    应用场景:
    同个控件在多个布局文件中使用,对该控件使用同一个style进行美化,如果需要该控件使用的id也一样,则可按如下方式使用:
    使用步骤:
    1、新建ids.xml文件

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <item type="id" name="toolbar" />
    </resources>
    

    2、styles.xml中

    <style name="CustomToolbar">
            <item name="android:id">@id/toolbar</item>
            <item name="android:layout_width">match_parent</item>
            <item name="android:layout_height">wrap_content</item>
            ...
        </style>
    

    相关文章

      网友评论

          本文标题:styles.xml中使用固定id的使用

          本文链接:https://www.haomeiwen.com/subject/yitzsqtx.html