本文介绍了TextAppearance.A继承自TextAppearance.A.B不会在android样式中引起循环引用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道

那么,这种样式是否具有循环继承?

so in this style, does it have a circular inheritance?

  <style name="TextAppearance.A" parent="TextAppearance.A.B">
    <item name="android:textAlignment">viewStart</item>
    <item name="android:gravity">start</item>
  </style>

由于Android点的语法,

TextAppearance.A.BTextAppearance.A继承.

TextAppearance.A.B inherits from TextAppearance.A because of android dots' syntax.

但是TextAppearance.A由于android paretn语法而从TextAppearance.A.B继承.

but TextAppearance.A inherits from TextAppearance.A.B because of android paretn syntax.

这真的有问题吗?

推荐答案

技术上,根据Android文档,我认为这是不可能的,因为这将导致样式的重复,所以如果您与钻石问题"所指的相同,它将是其中之一,而且android会阻止您从多个样式中进行继承.

Technically As per Android Documentation I dont think this is possible,Because this will lead to duplication of style, If you refer to same as Diamond Problem it will be one of those, also android prevents you from inheriting from more than one style.

进一步想象一下,如果您有一个在样式A以及样式B中定义的属性,那么在编译时就很难选择从这两个属性中选择哪个属性.

Further Imagine if you have one attribute which is defined in style A also in Style B, it will be a problem at compile time that which attribute to choose from both.

有关更多详细信息,请参阅android文档

For More Details please refer to android documentation

https://developer.android.com/guide /topics/ui/look-and-feel/themes

这篇关于TextAppearance.A继承自TextAppearance.A.B不会在android样式中引起循环引用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 17:26