dimanche 3 juillet 2016

SeekBar - Force thumb to show right away

In my app, I have a SeekBar that I use to allow the user to select a value. When my activity is first shown, the SeekBar's thumb is not shown, even though I set the SeekBar's Progress initial value in code. The thumb is only shown once the user physically touches the SeekBar. This makes it more difficult for the user to see the initial value before changing it.

How can I force the SeekBar to show the thumb immediately, without user interaction, either in XML or in code?

Here is the XML code for the SeekBar:

 <SeekBar
            android:id="@+id/SeekBar1Star"
            android:layout_height="match_parent"
            android:layout_width="0px"
            android:layout_weight="5"
            android:max="100"
            android:progress="50" />

Here is the code where I set the initial value:

_seekBar1Star = FindViewById<SeekBar>(Resource.Id.SeekBar1Star);
_seekBar1Star.Progress = starMix.Star1Mix;

The value in that last line is always between 0 and 100. I know that the Progress value is being set correctly because the blue bar "fills up" to the correct postion. The issue is that the thumb (dot) does not appear automatically.

Aucun commentaire:

Enregistrer un commentaire