只需要抽出来作为公共属性名就OK了
<?xml version="1.0" encoding="utf-8"?> <resources> <attr name="myattr1" format="string" /> <attr name="myattr2" format="dimension" /> <declare-styleable name="MyView1"> <attr name="myattr1" /> <attr name="myattr2" /> ... </declare-styleable> <declare-styleable name="MyView2"> <attr name="myattr1" /> <attr name="myattr2" /> ... </declare-styleable> </resources>原文链接:https://www.f2er.com/xml/297390.html