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

2019-02-09  本文已影响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>
上一篇 下一篇

猜你喜欢

热点阅读