use ViewUtils to calculate offset between SeekBar and SeekBarPanel
This commit is contained in:
1 parent
a0e957b1fd
commit
dcb11102f6
1 file changed
+4
-4
@@ -21,7 +21,6 @@ import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
@@ -55,9 +54,10 @@ public class SeekBarPanel extends LinearLayout {
|
||||
if (mSeekBar == null) {
|
||||
return super.onTouchEvent(event);
|
||||
} else {
|
||||
View containingView = (View) mSeekBar.getParent();
|
||||
final float offsetX = -(containingView.getLeft() + mSeekBar.getLeft());
|
||||
final float offsetY = -(containingView.getTop() + mSeekBar.getTop());
|
||||
int[] location = new int[2];
|
||||
ViewUtils.getLocationInAncestor(mSeekBar, location, this);
|
||||
final float offsetX = -location[0];
|
||||
final float offsetY = -location[1];
|
||||
event.offsetLocation(offsetX, offsetY);
|
||||
mSeekBar.onTouchEvent(event);
|
||||
event.offsetLocation(-offsetX, -offsetY);
|
||||
|
||||
Reference in new issue
Block a user