在Android 7.0设备上无法正确显示Slider / SeekBar(Moto G4)

时间:2017-04-19 12:23:55

标签: xamarin xamarin.android xamarin.forms slider seekbar

在我的xamarin表单应用中,我使用extendedsliders(带步长值的滑块)来设置照片质量和最高分辨率的值。在Android 6.0(Moto G2)和Android 6.0.1(Moto G3)上,滑块按预期显示。但是在Android 7.0(Moto G4)上只绘制了滑块的拇指。 (下图)

为了解决这个问题,我已经制作了一个效果并将其应用到滑块,如here所述,但这没有任何区别。

之前是否有人遇到此问题,您是否知道如何解决此问题?

ExtendedSlider

settings.Children.Add(qualitySlider = new ExtendedSlider
{
    Maximum = 80,
    Minimum = 50,
    StepValue = 1,
    Rotation = 180,
    HorizontalOptions = LayoutOptions.FillAndExpand,
    Margin = new Thickness(0, 0, 20, 0)
}, 2, 3);
qualitySlider.Effects.Add(Effect.Resolve("Effects.TauwSliderEffect"));
qualitySlider.ValueChanged += OnQualitySliderValueChanged;

效果

using Android.Widget;
using Xamarin.Forms.Platform.Android;
using Android.Graphics;
using Xamarin.Forms;
using SafetyIncidentsApp.Droid;

[assembly: ResolutionGroupName("Effects")]
[assembly: ExportEffect(typeof(TauwSliderEffect), "TauwSliderEffect")]
namespace SafetyIncidentsApp.Droid
{
    class TauwSliderEffect : PlatformEffect
    {
        protected override void OnAttached()
        {
            var seekBar = (SeekBar)Control;
            seekBar.ProgressDrawable.SetColorFilter(new PorterDuffColorFilter(Xamarin.Forms.Color.FromHex("#FF4081").ToAndroid(), PorterDuff.Mode.SrcIn));
            seekBar.Thumb.SetColorFilter(new PorterDuffColorFilter(Xamarin.Forms.Color.FromHex("#FF4081").ToAndroid(), PorterDuff.Mode.SrcIn));
        }

        protected override void OnDetached()
        {
        }
    }
}

Android 6.0.1和Android 7.0中滑块的屏幕截图

Example from Android 6.0.1 Example from Android 7.0

0 个答案:

没有答案