Priya Singhalが答えたように、Android Studioでは、共通の属性名を独自のスタイル名内で定義する必要があります。彼らはもうルートにいることはできません。
ただし、他にも注意すべきことがいくつかあります(そのため、私も回答を追加しています)。
- 一般的なスタイルには、ビューと同じ名前を付ける必要はありません。(それを指摘してくれたこの回答に感謝します。)
 
- 親との継承を使用する必要はありません。
 
例
これは、両方が同じ属性を共有する2つのカスタムビューを持つ最近のプロジェクトで私がやったことです。カスタムビューに属性の名前があり、が含まれていないformat限り、コードから通常どおりにアクセスできます。
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- common attributes to all custom text based views -->
    <declare-styleable name="TextAttributes">
        <attr name="text" format="string"/>
        <attr name="textSize" format="dimension"/>
        <attr name="textColor" format="color"/>
        <attr name="gravity">
            <flag name="top" value="48" />
            <flag name="center" value="17" />
            <flag name="bottom" value="80" />
        </attr>
    </declare-styleable>
    <!-- custom text views -->
    <declare-styleable name="View1">
        <attr name="text"/>
        <attr name="textSize"/>
        <attr name="textColor"/>
        <attr name="gravity"/>
    </declare-styleable>
    <declare-styleable name="View2">
        <attr name="text"/>
        <attr name="textSize"/>
        <attr name="textColor"/>
        <attr name="gravity"/>
    </declare-styleable>
</resources>
合理化された例
実際、属性をカスタム名の下に置く必要さえありません。format少なくとも1つのカスタムビューに対してそれらを定義する(それらにを与える)限り、どこでも(なしでformat)使用できます。したがって、これも機能します(そして見た目がきれいになります)。
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="View1">
        <attr name="text" format="string"/>
        <attr name="textSize" format="dimension"/>
        <attr name="textColor" format="color"/>
        <attr name="gravity">
            <flag name="top" value="48" />
            <flag name="center" value="17" />
            <flag name="bottom" value="80" />
        </attr>
    </declare-styleable>
    <declare-styleable name="View2">
        <attr name="text"/>
        <attr name="textSize"/>
        <attr name="textColor"/>
        <attr name="gravity"/>
    </declare-styleable>
</resources>
ただし、大規模なプロジェクトの場合、これは煩雑になる可能性があり、1つの場所の上部で定義する方がよい場合があります(ここで推奨)。
               
              
myattr1の文字列であるMyView1との整数はMyView2?