图库/适配器视图儿童绘制对象国适配器、视图、对象、图库

2023-09-06 09:22:42 作者:自先沉稳

我使用的是库视图,其中对应于每个项目的看法是不平凡的,由文字以及多个按钮。

I am using a Gallery view where the view corresponding to each item is non-trivial and consists of text as well as multiple buttons.

当我点击拖动图库视图(地方不是在按钮中的一个)pssed按钮的绘制状态更改为$ P $和看起来好像所有的按钮,目前正在pressed。此外,相同的行为发生为选中状态(例如,所有的孩子TextViews改变颜色的文本)。

When I click to drag the gallery view (somewhere not on one of the buttons) the button's drawable state changes to pressed and appears as if all of the buttons are currently being pressed. Additionally, the same behavior happens for the selected state (e.g. all of the text of the child TextViews changes color).

我想prevent这种行为,并发现了android:duplicateParentState XML属性还有setDuplicateParentStateEnabled财产。这似乎像它应该做到什么,我试图做的,但它似乎没有任何效果。

I am trying to prevent this behavior and have found the android:duplicateParentState xml attribute as well as the setDuplicateParentStateEnabled property. This seems like it should accomplish what I am trying to do, but it seems to have no effect.

任何想法?

推荐答案

不知道在哪里的duplicateParentState属性发挥作用,而是通过源突破表明,这是从来没有考虑到所选择和pressed状态。我会创造出一个自定义视图类并覆盖dispatchSetSelected和dispatchSet $​​ P $ pssed方法。

Not sure where the duplicateParentState property comes into play, but breaking through the source shows that it is never taken into account for the selected and pressed states. I would up creating a custom view class and overriding the dispatchSetSelected and dispatchSetPressed methods.