Fix a bug so when user clicks the SeekBarPanel, the x coordinate with the correct x-offset is sent to SeekBar.

This commit is contained in:
bfkro authored and seven332 committed 2018-03-21 19:25:12 +08:00
1 parent c8c0a3aae0
commit a0e957b1fd
1 file changed
+4 -2
@@ -21,6 +21,7 @@ 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;
@@ -54,8 +55,9 @@ public class SeekBarPanel extends LinearLayout {
if (mSeekBar == null) {
return super.onTouchEvent(event);
} else {
final float offsetX = -mSeekBar.getLeft();
final float offsetY = -mSeekBar.getTop();
View containingView = (View) mSeekBar.getParent();
final float offsetX = -(containingView.getLeft() + mSeekBar.getLeft());
final float offsetY = -(containingView.getTop() + mSeekBar.getTop());
event.offsetLocation(offsetX, offsetY);
mSeekBar.onTouchEvent(event);
event.offsetLocation(-offsetX, -offsetY);