涟漪效应方向问题

时间:2016-05-04 09:49:19

标签: android animation layout ripple rippledrawable

当我触摸布局的边框(使用RippleDrawable作为背景的线性布局)时,涟漪效果不会在点击的点开始,而是在 波纹也传播到中心。

RippleDrawable drawable = new RippleDrawable(ColorStateList.valueOf(pressedColor), null, getRippleMask(baseColor)); this.setBackground(drawable);

我还尝试使用setHotspot方法作为坐标(0,0)并且它不会从左上角开始。

2 个答案:

答案 0 :(得分:0)

尝试这种方法可能对你有用

private void startRippleAnimation(View v, float x, float y){
   Drawable background = v.getBackground();
   if(background instanceof RippleDrawable){
     RippleDrawable ripple = (RippleDrawable)background;
     ripple.setHotspot(x, y);
     ripple.setVisible (true, true);
   }

}

答案 1 :(得分:0)

setHotspotBound(x,y,x,y)

之前使用setHotspot(x,y)方法解决
相关问题