我的style.xml中是否有多余的继承?

时间:2018-12-23 10:14:46

标签: android inheritance styles

我有这种android风格:

<resources>   <style name="TextAppearance.A.B.Base" parent="TextAppearance.AppCompat">
    <item name="android:ellipsize">end</item>
    <item name="android:gravity">start</item>
    <item name="android:maxLines">1</item>   </style>

  <style name="TextAppearance.A.B" parent="TextAppearance.A.B.Base"/>

  <style name="TextAppearance.A.B.C" parent="TextAppearance.A.B">
    <item name="fontFamily">@font/google_sans_medium</item>
    <item name="android:textSize">14sp</item>

为什么需要中间人?

  <style name="TextAppearance.A.B" parent="TextAppearance.A.B.Base"/>

不是吗?

    <resources>   <style name="TextAppearance.A.B.Base" parent="TextAppearance.AppCompat">
        <item name="android:ellipsize">end</item>
        <item name="android:gravity">start</item>
        <item name="android:maxLines">1</item>   </style>

      <style name="TextAppearance.A.B.C" parent="TextAppearance.A.B.Base">
        <item name="fontFamily">@font/google_sans_medium</item>
        <item name="android:textSize">14sp</item>
</style>

我在现有代码中看到了它,并且不确定为什么需要此项。

还有namespace inheritanceexplicit inheritance吗?

所以这也行吗?

    <resources>   <style name="TextAppearance.AppCompat.A.B.Base">
        <item name="android:ellipsize">end</item>
        <item name="android:gravity">start</item>
        <item name="android:maxLines">1</item>   </style>

      <style name="TextAppearance.AppCompat.A.B.Base">
        <item name="fontFamily">@font/google_sans_medium</item>
        <item name="android:textSize">14sp</item>
</style>

parent属性仅用于使名称空间不太长?

0 个答案:

没有答案