Gallery/AdapterView Child Drawable State

前端 未结 3 1681
心在旅途
心在旅途 2021-01-12 09:29

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.

When I click to drag the gallery

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-12 10:28

    Maybe a bit on the late side, but having run into this problem myself recently I have a fix.

    dispatchSetSelected and dispatchSetPressed don't really help here, as the methods you actually need to override are private within Gallery.

    The solution is to add an extra layout (I used a subclass of LinearLayout) around the child view, which overrides setPressed(boolean) and simply ignores it. This prevents the gallery from forcing its pressed state on the children, while still allowing those children to be activated directly, and not stopping events from being propagated upwards.

提交回复
热议问题