public static void SetTheme(SeekBar seekBar, FlatTheme theme) { // setting thumb var thumb = new PaintDrawable(theme.DarkAccentColor); thumb.SetCornerRadius(15); thumb.SetIntrinsicWidth(30); thumb.SetIntrinsicHeight(30); seekBar.SetThumb(thumb); // progress var progress = new PaintDrawable(theme.BackgroundColor); progress.SetCornerRadius(10); progress.SetIntrinsicHeight(10); progress.SetIntrinsicWidth(5); progress.SetDither(true); var progressClip = new ClipDrawable(progress, GravityFlags.Left, ClipDrawableOrientation.Horizontal); // secondary progress var secondary = new PaintDrawable(theme.LightAccentColor); secondary.SetCornerRadius(10); secondary.SetIntrinsicHeight(10); var secondaryProgressClip = new ClipDrawable(secondary, GravityFlags.Left, ClipDrawableOrientation.Horizontal); // background PaintDrawable background = new PaintDrawable(theme.VeryLightAccentColor); background.SetCornerRadius(10); background.SetIntrinsicHeight(10); // applying drawable LayerDrawable ld = (LayerDrawable) seekBar.ProgressDrawable; ld.SetDrawableByLayerId(Android.Resource.Id.Background, background); ld.SetDrawableByLayerId(Android.Resource.Id.Progress, progressClip); ld.SetDrawableByLayerId(Android.Resource.Id.SecondaryProgress, secondaryProgressClip); }
public static void SetTint(SeekBar seekBar, Color color) { ColorStateList s1 = ColorStateList.ValueOf(color); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { seekBar.ThumbTintList = s1; seekBar.ProgressTintList = s1; } else if (Build.VERSION.SdkInt > BuildVersionCodes.GingerbreadMr1) { Drawable progressDrawable = DrawableCompat.Wrap(seekBar.ProgressDrawable); seekBar.ProgressDrawable = progressDrawable; DrawableCompat.SetTintList(progressDrawable, s1); if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean) { Drawable thumbDrawable = DrawableCompat.Wrap(seekBar.Thumb); DrawableCompat.SetTintList(thumbDrawable, s1); seekBar.SetThumb(thumbDrawable); } } else { PorterDuff.Mode mode = PorterDuff.Mode.SrcIn; if (Build.VERSION.SdkInt <= BuildVersionCodes.GingerbreadMr1) { mode = PorterDuff.Mode.Multiply; } if (seekBar.IndeterminateDrawable != null) seekBar.IndeterminateDrawable.SetColorFilter(color, mode); if (seekBar.ProgressDrawable != null) seekBar.ProgressDrawable.SetColorFilter(color, mode); } }
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e) { base.OnElementChanged(e); control = (SeekBar)Control; //control.ScaleY = 3; //control.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.drag_bg)); formsSlider = (CustomSlider)this.Element; formsSlider.Value = 1; formsSlider.CurrentValue = 1; FeelingNowPage.sliderValue = 1; Android.Graphics.Drawables.Drawable drawable = Resources.GetDrawable(Resource.Drawable.drag_btn); control.SetThumb(drawable); control.ProgressChanged += control_ProgressChanged; control.StopTrackingTouch += control_StopTrackingTouch; control.StartTrackingTouch += control_StartTrackingTouch; }
private void ChangeSeekBarColorAnalyzerNotFailed(SeekBar seekBar) { if ((seekBar.Progress == MaxProgress && AnalyzerSuccessful) || seekBar.Progress == 0) { seekBar.SetThumb(Resources.GetDrawable(Resource.Drawable.thumb_green)); seekBar.ProgressDrawable = Resources.GetDrawable(Resource.Drawable.progress_seekbar_green); return; } seekBar.SetThumb(Resources.GetDrawable(Resource.Drawable.thumb_yellow)); seekBar.ProgressDrawable = Resources.GetDrawable(Resource.Drawable.progress_seekbar_yellow); }
private void ChangeSeekBarColor(SeekBar seekBar) { if (AnalyzerFailed) { seekBar.SetThumb(Resources.GetDrawable(Resource.Drawable.thumb_red)); seekBar.ProgressDrawable = Resources.GetDrawable(Resource.Drawable.progress_seekbar_red); return; } ChangeSeekBarColorAnalyzerNotFailed(seekBar); }
private void InitializeUi(Activity activity) { if (IsUiInitialized) return; _startButton = activity.FindViewById<Button>(Resource.Id.StartButton); _startButton.Enabled = EnableStartButtonFlag; _cancelButton = activity.FindViewById<Button>(Resource.Id.CancelButton); _feedbackButton = activity.FindViewById<Button>(Resource.Id.FeedbackButton); _statusText = activity.FindViewById<TextView>(Resource.Id.StatusText); _resultText = activity.FindViewById<TextView>(Resource.Id.Result); _animationView = activity.FindViewById<ImageView>(Resource.Id.AnimationView); _smartPhoneView = activity.FindViewById<ImageView>(Resource.Id.SmartphoneImage); _resultViews = activity.FindViewById<LinearLayout>(Resource.Id.ResultsView); _countdownText = activity.FindViewById<TextView>(Resource.Id.CountdownText); _manualText = activity.FindViewById<TextView>(Resource.Id.ManualText1); _manualText2 = activity.FindViewById<TextView>(Resource.Id.ManualText2); _progressBar = activity.FindViewById<SeekBar>(Resource.Id.SeekBar); _progressBar.SetOnSeekBarChangeListener(this); _progressBar.Touch += OnTouchProgressBar; _progressBar.SetThumb(activity.Resources.GetDrawable(Resource.Drawable.thumb_green)); _progressBar.ProgressDrawable = activity.Resources.GetDrawable(Resource.Drawable.progress_seekbar_green); _progressBar.Max = MaxProgress; _progressBar.Progress = 0; _dontShowAgainBox = activity.FindViewById<CheckBox>(Resource.Id.DontShowAgainBox); _dontShowAgainBox.Visibility = ViewStates.Invisible; var preferences = PreferenceManager.GetDefaultSharedPreferences(SkillStoreApplication.AppContext); _dontShowAgainBox.Checked = preferences.GetBoolean(SettingsKey.ShowAgainPreference, false); IsUiInitialized = true; }