diff --git a/RangeSeekBar/src/main/java/com/jaygoo/widget/RangeSeekbar.java b/RangeSeekBar/src/main/java/com/jaygoo/widget/RangeSeekbar.java
index 3ecbd49..4f1ee3b 100755
--- a/RangeSeekBar/src/main/java/com/jaygoo/widget/RangeSeekbar.java
+++ b/RangeSeekBar/src/main/java/com/jaygoo/widget/RangeSeekbar.java
@@ -181,7 +181,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
- heightNeeded = mThumbSize + mCursorTextHeight + (int)mHintBGHeight + 2 * DEFALT_PADDING + mHintBGPadding;
+ heightNeeded = mThumbSize + mCursorTextHeight + (int)mHintBGHeight + 2 * DEFALT_PADDING
+ + mHintBGPadding + getPaddingTop() + getPaddingBottom();
/**
* onMeasure传入的widthMeasureSpec和heightMeasureSpec不是一般的尺寸数值,而是将模式和尺寸组合在一起的数值
@@ -210,10 +211,10 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// Calculates the position of the progress bar and initializes the positions of
// the two buttons based on it
- lineLeft = 2 * DEFALT_PADDING;
- lineRight = w - 2 * DEFALT_PADDING;
- lineTop = (int)mHintBGHeight+ mThumbSize/2 -mSeekbarHight/2 + DEFALT_PADDING;
- lineBottom = lineTop + mSeekbarHight;
+ lineLeft = 2 * DEFALT_PADDING + (int)(mHintBGWith/2) + getPaddingLeft();
+ lineRight = w - lineLeft - getPaddingRight();
+ lineTop = (int)mHintBGHeight+ mThumbSize/2 -mSeekbarHight/2 + DEFALT_PADDING + getPaddingTop();
+ lineBottom = lineTop + mSeekbarHight - getPaddingBottom();
lineWidth = lineRight - lineLeft;
line.set(lineLeft, lineTop, lineRight, lineBottom);
lineCorners = (int) ((lineBottom - lineTop) * 0.45f);
@@ -720,8 +721,11 @@ public float[] getCurrentRange() {
}
}
- public void setEnable(boolean isEnable){
- this.isEnable = isEnable;
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ this.isEnable = enabled;
}
public void setProgress(String progress){
@@ -765,6 +769,12 @@ public boolean onTouchEvent(MotionEvent event) {
touchResult = true;
}
+
+ //Intercept parent TouchEvent
+ if(getParent() != null) {
+ getParent().requestDisallowInterceptTouchEvent(true);
+ }
+
return touchResult;
case MotionEvent.ACTION_MOVE:
@@ -812,6 +822,11 @@ public boolean onTouchEvent(MotionEvent event) {
}
leftSB.slide(percent);
leftSB.isShowingHint = true;
+
+ //Intercept parent TouchEvent
+ if(getParent() != null) {
+ getParent().requestDisallowInterceptTouchEvent(true);
+ }
} else if (currTouch == rightSB) {
if (cellsCount > 1) {
if (x > lineRight) {
@@ -847,12 +862,28 @@ public boolean onTouchEvent(MotionEvent event) {
callback.onRangeChanged(this, result[0], result[1],true);
}
invalidate();
+
+ //Intercept parent TouchEvent
+ if(getParent() != null) {
+ getParent().requestDisallowInterceptTouchEvent(true);
+ }
break;
case MotionEvent.ACTION_CANCEL:
if (mSeekBarMode == 2) {
rightSB.isShowingHint = false;
}
leftSB.isShowingHint = false;
+
+ if (callback != null) {
+ float[] result = getCurrentRange();
+ callback.onRangeChanged(this, result[0], result[1],false);
+ }
+
+ //Intercept parent TouchEvent
+ if(getParent() != null) {
+ getParent().requestDisallowInterceptTouchEvent(true);
+ }
+
break;
case MotionEvent.ACTION_UP:
if (mSeekBarMode == 2) {
@@ -863,7 +894,12 @@ public boolean onTouchEvent(MotionEvent event) {
if (callback != null) {
float[] result = getCurrentRange();
- callback.onRangeChanged(this, result[0], result[1],true);
+ callback.onRangeChanged(this, result[0], result[1],false);
+ }
+
+ //Intercept parent TouchEvent
+ if(getParent() != null) {
+ getParent().requestDisallowInterceptTouchEvent(true);
}
break;
}
diff --git a/RangeSeekBar/src/main/res/values/colors.xml b/RangeSeekBar/src/main/res/values/colors.xml
index e85305a..21a06b4 100644
--- a/RangeSeekBar/src/main/res/values/colors.xml
+++ b/RangeSeekBar/src/main/res/values/colors.xml
@@ -3,6 +3,6 @@
#3F51B5
#303F9F
#2ed184
- #c3c3c3
+ #c3c3c3
diff --git a/app/src/main/java/com/jaygoo/demo/MainActivity.java b/app/src/main/java/com/jaygoo/demo/MainActivity.java
index c14175a..df2832c 100644
--- a/app/src/main/java/com/jaygoo/demo/MainActivity.java
+++ b/app/src/main/java/com/jaygoo/demo/MainActivity.java
@@ -2,6 +2,7 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.view.View;
import android.widget.TextView;
import com.jaygoo.widget.RangeSeekbar;
@@ -12,6 +13,7 @@ public class MainActivity extends AppCompatActivity {
private RangeSeekbar seekbar2;
private TextView tv2;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -41,4 +43,5 @@ public void onRangeChanged(RangeSeekbar view, float min, float max, boolean isFr
});
}
+
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 969404d..1787c35 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -17,7 +17,7 @@
app:markTextArray="@array/markArray"
app:lineColorSelected="@color/colorAccent"
app:seekBarResId="@drawable/seekbar_thumb"
- app:lineColorEdge="@color/colorSeekBarDefalut"
+ app:lineColorEdge="@color/colorSeekBarDefault"
app:cellMode="number"
app:seekBarMode="single"
/>
@@ -30,20 +30,19 @@
+