且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RippleDrawable没有结束绘制意见

更新时间:2023-02-22 13:40:18

,你可以从自己的code见('的setBackground'),你设置纹​​波为背景这就是为什么它被在背景绘制。

as you can see from your own code ('setBackground') , you're setting the ripple as a BACKGROUND that's why it's being drawn on the background.

在Android API 21 ImageView的添加了这个黑客为纹波的android:drawSelectorOnTop =真正的。但是,你正在使用的库并没有同样的黑客添加到它。

ImageView on android API 21 added this "hack" for the ripple android:drawSelectorOnTop="true". But the library you're using didn't add the same hack to it.

有什么不对本身的code。但是,这种类型的行为不能由Android团队的第三方库得到保障。

There's nothing wrong itself on your code. But this type of behavior cannot be guaranteed by the Android team for 3rd party libraries.

您有几个在这里的选项,将在清洁,努力和表现各不相同:

You have a few of options here that will vary on cleanliness, effort and performance:


  1. 检查ImageView的源$ C ​​$ C,克隆库,添加相同破解它用于纹波ImageView的。它的正常工作后,请一定要拉请求回库。

  2. 包装你的 KenBurnsView 用的FrameLayout,并使用 setForeground 上的FrameLayout设置纹波。

  3. 克隆库,前景绘制添加选项,它(类似于此How设置前景色属性其他非的FrameLayout视图)。另外,请一定要拉这个要求居停code回库。

  1. check ImageView source code, clone the library, add the same hack that imageview used on it for the ripple. After it's working fine, make sure to pull request back to the library.
  2. wrap your KenBurnsView with a FrameLayout and set the ripple using setForeground on the FrameLayout.
  3. clone the library, add option to foreground drawable to it (similar to this How to set foreground attribute to other non FrameLayout view). Also make sure to pull request this valueable code back to the library.