diff --git a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java index ff45ec1..0de25ae 100644 --- a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java +++ b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java @@ -97,6 +97,7 @@ public class BubbleSeekBar extends View { private float mBubbleCenterRawX; // 气泡的实时RawX private WindowManager.LayoutParams mLayoutParams; private int[] mPoint = new int[2]; + private long mAnimDuration = 200; public BubbleSeekBar(Context context) { this(context, null); @@ -144,6 +145,8 @@ public BubbleSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { isShowSectionMark = a.getBoolean(R.styleable.BubbleSeekBar_bsb_show_section_mark, false); isAutoAdjustSectionMark = a.getBoolean(R.styleable.BubbleSeekBar_bsb_auto_adjust_section_mark, false); isShowProgressInFloat = a.getBoolean(R.styleable.BubbleSeekBar_bsb_show_progress_in_float, false); + int duration = a.getInteger(R.styleable.BubbleSeekBar_bsb_anim_duration, -1); + mAnimDuration = duration < 0 ? 200 : duration; a.recycle(); if (mMin > mMax) { @@ -456,7 +459,7 @@ public boolean onTouchEvent(MotionEvent event) { if (isAutoAdjustSectionMark) { autoAdjustSection(); } else if (isThumbOnDragging) { - mBubbleView.animate().alpha(0f).setDuration(200) + mBubbleView.animate().alpha(0f).setDuration(mAnimDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -531,7 +534,7 @@ private void showBubble() { mBubbleView.setAlpha(0); mBubbleView.setVisibility(VISIBLE); - mBubbleView.animate().alpha(1f).setDuration(200) + mBubbleView.animate().alpha(1f).setDuration(mAnimDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { @@ -594,9 +597,9 @@ public void onAnimationUpdate(ValueAnimator animation) { ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mBubbleView, View.ALPHA, 0); if (onSection) { - animatorSet.setDuration(200).play(alphaAnim); + animatorSet.setDuration(mAnimDuration).play(alphaAnim); } else { - animatorSet.setDuration(200).playTogether(valueAnim, alphaAnim); + animatorSet.setDuration(mAnimDuration).playTogether(valueAnim, alphaAnim); } animatorSet.addListener(new AnimatorListenerAdapter() { @Override diff --git a/bubbleseekbar/src/main/res/values/attr.xml b/bubbleseekbar/src/main/res/values/attr.xml index de367c1..006d722 100644 --- a/bubbleseekbar/src/main/res/values/attr.xml +++ b/bubbleseekbar/src/main/res/values/attr.xml @@ -28,5 +28,6 @@ + \ No newline at end of file