public static void SetOutlineProvider(View view, MarkerDrawable markerDrawable) { if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { SeekBarCompatDontCrash.SetOutlineProvider(view, markerDrawable); } }
public Marker(Context context, IAttributeSet attrs, int defStyleAttr, String maxValue, int thumbSize, int separation) : base(context, attrs, defStyleAttr) { Visibility = ViewStates.Visible; DisplayMetrics displayMetrics = context.Resources.DisplayMetrics; TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.DiscreteSeekBar, Resource.Attribute.discreteSeekBarStyle, Resource.Style.Widget_DiscreteSeekBar); int padding = (int)(PADDING_DP * displayMetrics.Density) * 2; int textAppearanceId = a.GetResourceId(Resource.Styleable.DiscreteSeekBar_dsb_indicatorTextAppearance, Resource.Style.Widget_DiscreteIndicatorTextAppearance); mNumber = new TextView(context); //Add some padding to this textView so the bubble has some space to breath mNumber.SetPadding(padding, 0, padding, 0); mNumber.SetTextAppearance(context, textAppearanceId); mNumber.Gravity = GravityFlags.Center; mNumber.Text = maxValue; mNumber.SetMaxLines(1); mNumber.SetSingleLine(true); SeekBarCompat.SetTextDirection(mNumber, (int)TextDirectionLocale); mNumber.Visibility = ViewStates.Invisible; //add some padding for the elevation shadow not to be clipped //I'm sure there are better ways of doing this... SetPadding(padding, padding, padding, padding); ResetSizes(maxValue); mSeparation = separation; ColorStateList color = a.GetColorStateList(Resource.Styleable.DiscreteSeekBar_dsb_indicatorColor); mMarkerDrawable = new MarkerDrawable(color, thumbSize); mMarkerDrawable.SetCallback(this); mMarkerDrawable.SetMarkerListener(this); mMarkerDrawable.SetExternalOffset(padding); //Elevation for anroid 5+ float elevation = a.GetDimension(Resource.Styleable.DiscreteSeekBar_dsb_indicatorElevation, ELEVATION_DP * displayMetrics.Density); ViewCompat.SetElevation(this, elevation); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { SeekBarCompat.SetOutlineProvider(this, mMarkerDrawable); } a.Recycle(); }
public static void SetOutlineProvider(View marker, MarkerDrawable markerDrawable) { marker.OutlineProvider = new SeekBarViewOutlineProdiver { MarkerDrawable = markerDrawable }; }