日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

Andorid 自定義 View - 自定義屬性 - 屬性重復(fù)導(dǎo)致沖突

作者:teletian 更新時(shí)間: 2022-07-13 編程語言

先來看一個(gè)自定義屬性重復(fù)的例子:

attrs.xml

<resources>
    <declare-styleable name="View1">
        <attr name="title_color" format="color" />
    </declare-styleable>

    <declare-styleable name="View2">
        <attr name="title_color" format="color" />
    </declare-styleable>
</resources>

這樣會報(bào)錯如下:
Found item Attr/color_type more than one time

解決辦法也很簡單,把相同的屬性抽出來定義就可以。

<resources>
    <attr name="title_color" format="color" />

    <declare-styleable name="View1">
        <attr name="title_color" />
     </declare-styleable>

    <declare-styleable name="View2">
        <attr name="title_color" />
    </declare-styleable>
</resources>

原文鏈接:https://blog.csdn.net/tianjf0514/article/details/125750217

欄目分類
最近更新