List of usage examples for android.widget AbsoluteLayout setBackgroundDrawable
@Deprecated public void setBackgroundDrawable(Drawable background)
From source file:com.hippo.widget.Slider.java
@SuppressWarnings("deprecation") private void init(Context context, AttributeSet attrs) { mContext = context;//from ww w.j a v a 2s . c o m mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextAlign(Paint.Align.CENTER); Resources resources = context.getResources(); mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width); mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height); mBubble = new BubbleView(context, textPaint); mBubble.setScaleX(0.0f); mBubble.setScaleY(0.0f); AbsoluteLayout absoluteLayout = new AbsoluteLayout(context); absoluteLayout.addView(mBubble); absoluteLayout.setBackgroundDrawable(null); mPopup = new PopupWindow(absoluteLayout); mPopup.setOutsideTouchable(false); mPopup.setTouchable(false); mPopup.setFocusable(false); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider); textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE)); textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12)); updateTextSize(); setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0)); setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0)); mThickness = a.getDimension(R.styleable.Slider_thickness, 2); mRadius = a.getDimension(R.styleable.Slider_radius, 6); setColor(a.getColor(R.styleable.Slider_color, Color.BLACK)); mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000); a.recycle(); mProgressAnimation = new ValueAnimator(); mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR); mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(@NonNull ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mDrawPercent = value; mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value)); updateBubblePosition(); mBubble.setProgress(mDrawProgress); invalidate(); } }); mBubbleScaleAnimation = new ValueAnimator(); mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(@NonNull ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mDrawBubbleScale = value; mBubble.setScaleX(value); mBubble.setScaleY(value); invalidate(); } }); }