title: Decimal values in seek bar in Android
body: <p>I am working on android application in which i am using seek bar. In which my range is from 0 - 20 and starting value is 5. For numeric values it is working fine, but now i want to make it for decimal values but the range should be from 0.0 to 20.0. My code for numeric is given below:</p>
  
  <pre><code>SeekBar seek=(SeekBar) findViewById(R.id.seekBar1);
          seek.setProgress(5);
          seek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
                          // TODO Auto-generated method stub
          }
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
          textView.setText( progress + " km");// + seekBar.getMax());
          distance = progress;
          }
          });
  </code></pre>
  
  <p>XML for seek bar:</p>
  
  <pre><code>&lt;TextView
              android:id="@+id/txtSeekBar"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:layout_marginBottom="10dp"
              android:text="5 km"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:textColor="@color/gray" /&gt;
  </code></pre>
  
  <p>I have used this sample code for decimal values but it is not working.</p>
  
  <pre><code>SeekBar seek=(SeekBar) findViewById(R.id.seekBar1);
          seek.setProgress(5);
  
  
          seek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
                          // TODO Auto-generated method stub
          }
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
  
          double value = ((float)progress / 20.0);
          String yourprogress = String.valueOf(value);
          textView.setText( yourprogress + " km");// + seekBar.getMax());
          distance = (int) value;
          }
          });
  </code></pre>