如何通过代码设置Seek Bar拇指



我正在尝试使用代码而不是XML 来设置seekbar拇指

我试过

Drawable a = null;
a = Drawable.CreateFromStream(Assets.Open("Drawable/Icon"),null);
seekBar.SetThumb (a);

也尝试过:

seekBar.SetThumb() //Adding the image path but it said the it requires a drawable but it was giving it a int

如何使用代码设置图像?

我也在使用Xamarin免费版本。

我遇到了同样的问题,我用下面的代码解决了它。希望它能帮助

public void seek_bar_ProgressChanged(object sender, SeekBar.ProgressChangedEventArgs e) {
    Bitmap img = BitmapFactory.DecodeResource(Resources, Resource.Drawable.yellobar);
    Drawable d = new BitmapDrawable(Resources, img);
    seek_bar.ProgressDrawable = d;
}

最新更新