Xamarin 如何通过代码设置搜索条?
我试图使用代码而不是XML设置seekbar thumb 我试过了Xamarin 如何通过代码设置搜索条?,xamarin,xamarin.android,xamarin-studio,Xamarin,Xamarin.android,Xamarin Studio,我试图使用代码而不是XML设置seekbar thumb 我试过了 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
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;
}