【发布时间】:2015-01-18 02:01:52
【问题描述】:
我正在使用 ForegroundLinearLayout (https://github.com/gabrielemariotti/cardslib/blob/master/library-core/src/main/java/it/gmariotti/cardslib/library/view/ForegroundLinearLayout.java)。 这是一个非常简单的实现。
但是,我已经在 RecyclerViews 中放置了一些 ForegroundLinearLayouts,有时(大约 50% 的时间)在视图被回收之前,我的前景的按下状态不会出现(我向下滚动到视图的第一个屏幕) .
我认为问题出在 mForegroundDrawable.setState(getDrawableState())。
我发现在我的 ForegroundLinearLayouts 中调用了 drawableStateChanged(),当我按下并释放 View 时 getDrawableState() 显示正确的值,并且 mForegroundDrawable.setState(getDrawableState()) 甚至返回 true。
即使在 ForegroundLinearLayout 中显式调用 mForegroundDrawable.invalidateSelf() 和 this.invalidate() 也无济于事。
按下状态大约 50% 的时间不会出现在视图的第一个屏幕上。使用视图的背景有效,但前景无效。
有人知道什么是坏的吗?
我真的不想将我所有的 ForegroundLinearLayouts 都包装在 FrameLayouts 中。
【问题讨论】:
标签: android android-view drawable android-framelayout