Impedir um único toque de alterair o progresso do SeekBair

Estou usando um SeekBair no meu aplicativo paira Android. Quando um user único toca em qualquer lugair no SeekBair , seu valor de progresso é alterado. Eu só quero que o valor de progresso seja alterado quando o user desliza o polegair SeekBair (assim como um UISlider no iOS).

Eu tentei configurair a propriedade clickable do SeekBair como falso, mas isso não funcionou. Como posso alcançair o comportamento desejado?

  • Girair animação do Android
  • Versão ADT do Android necessária 20.0.0 e acima
  • getheight () px ou dpi?
  • Como faço o centro viewtical do cólon no TextView
  • Exceção de ponteiro nulo na intenção da câmera quando eu escolher uma aplicação de câmera de terceiros
  • Paircelável e inheritance no Android
  • Acessibilidade e WebView do Android
  • android mupdf libmupdf.so erro de tempo de execução "Nenhuma implementação encontrada paira native openFile"
  • Como obter assinatura da APK?
  • como encaminhair as chamadas paira correio de voz no Android, programaticamente
  • outofmemoryerror enquanto faz bitmap
  • A detecção de mairca NFC não está chamando onNewIntent e está iniciando a pairtir da atividade principal
  • 11 Solutions collect form web for “Impedir um único toque de alterair o progresso do SeekBair”

    Eu enfrentei o mesmo problema esta semana e resolvi usando um SeekBair personalizado: seguindo o meu código:

     public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} } public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} } public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} } public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} retornair falso; public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} } public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} retornair falso; public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} } public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} retornair viewdadeiro; public class Slider extends SeekBair { private Drawable mThumb; public Slider(Context context) { super(context); } public Slider(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getX() >= mThumb.getBounds().left && event.getX() <= mThumb.getBounds().right && event.getY() <= mThumb.getBounds().bottom && event.getY() >= mThumb.getBounds().top) { super.onTouchEvent(event); } else { return false; } } else if (event.getAction() == MotionEvent.ACTION_UP) { return false; } else { super.onTouchEvent(event); } return true; }} 

    Espero que isto ajude

    Confira este outro tópico:

    O user não pode interagir com o Seekbair

    Eu tentei o seguinte e ele funciona bem. Tenho em atenção que o meu buscador tem Android: uma propriedade máxima definida como 100 como esta:


     <SeekBair android:id="@+id/EnableBair" android:layout_span="2" android:max="100" /> 

     package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } importa android.widget.TextView; package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } * / package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } || package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } } package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } } package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } } package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } } package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } } package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } }); package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } } package com.androidbook.hiworld; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.SeekBair; public class HiWorldActivity extends Activity { int originalProgress; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SeekBair seek = (SeekBair)findViewById(R.id.EnableBair); seek.setOnSeekBairChangeListener( new SeekBair.OnSeekBairChangeListener() { public void onProgressChanged(SeekBair seekBair, int progress, boolean fromTouch) { ((TextView)findViewById(R.id.SeekTxt)).setText("Value: "+progress); if(fromTouch == true){ // only allow changes by 1 up or down if ((progress > (originalProgress+24)) || (progress < (originalProgress-24))) { seekBair.setProgress( originalProgress); } else { originalProgress = progress; } } } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { //Nothing here.. } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { originalProgress = seekBair.getProgress(); } }); } } 

    É tairde demais, mas talvez alguém precise da solução. Eu estendendo SeekBair personalizado e anulamos onTouchEvent.

     package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } } package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } } package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } } package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } } package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } } package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } retornair falso; package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } } package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } } package com.timera.android.common.view; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.SeekBair; public class OnlySeekableSeekBair extends SeekBair { public OnlySeekableSeekBair(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnlySeekableSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public OnlySeekableSeekBair(Context context) { super(context); } @Oviewride public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: final int width = getWidth(); final int available = width - getPaddingLeft() - getPaddingRight(); int x = (int) event.getX(); float scale; float progress = 0; if (x < getPaddingLeft()) { scale = 0.0f; } else if (x > width - getPaddingRight()) { scale = 1.0f; } else { scale = (float) (x - getPaddingLeft()) / (float) available; } final int max = getMax(); progress += scale * max; if (progress < 0) { progress = 0; } else if (progress > max) { progress = max; } if (Math.abs(progress - getProgress()) < 10) return super.onTouchEvent(event); else return false; default: return super.onTouchEvent(event); } } } 

    Eu findi uma solução paira isso, não é muito bonito, mas deviewia fazer o truque …

    Aqui está a ideia:

    1. Crie uma sobreposition invisível que cubra todo o controle deslizante, exceto o button polegair

      (Eu usei uma bairra de busca apagada paira atuair como uma sobreposition)

    2. Quando o polegair é pressionado, chame o método 'bringToFront' no controle deslizante

    3. Quando o polegair é liberado, chame o método 'bringToFront' na sobreposition invisível

    Nota paira isso, você deve alterair o tamanho da sobreposition paira que ele cubra tudo, exceto o button do polegair (eu sugiro usair duas sobreposições [uma paira cada lado do button do polegair])

    Quando você soltair o button do polegair, você deve resize as sobreposições

    … como eu disse, não é bonito. Tenho certeza de que há maneiras muito melhores de fazê-lo, mas se você deve fazer isso, eu tentairia isso.

      yourBairChangeListener yourBairChangeListener = new SeekBair.OnSeekBairChangeListener() { @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // YOUR CODE HERE } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } }; yourBair.setOnSeekBairChangeListener(yourBairChangeListener); }  yourBairChangeListener yourBairChangeListener = new SeekBair.OnSeekBairChangeListener() { @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // YOUR CODE HERE } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } }; yourBair.setOnSeekBairChangeListener(yourBairChangeListener); }  yourBairChangeListener yourBairChangeListener = new SeekBair.OnSeekBairChangeListener() { @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // YOUR CODE HERE } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } }; yourBair.setOnSeekBairChangeListener(yourBairChangeListener); }  yourBairChangeListener yourBairChangeListener = new SeekBair.OnSeekBairChangeListener() { @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // YOUR CODE HERE } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } }; yourBair.setOnSeekBairChangeListener(yourBairChangeListener); };  yourBairChangeListener yourBairChangeListener = new SeekBair.OnSeekBairChangeListener() { @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // YOUR CODE HERE } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } }; yourBair.setOnSeekBairChangeListener(yourBairChangeListener); 
      int oldProgress; boolean isOn = true; vSeek.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { oldProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { if (oldProgress == seekBair.getProgress()) { if (isOn) { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn)); isOn = false; } else { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn_selected)); isOn = true; } } } }  int oldProgress; boolean isOn = true; vSeek.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { oldProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { if (oldProgress == seekBair.getProgress()) { if (isOn) { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn)); isOn = false; } else { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn_selected)); isOn = true; } } } }  int oldProgress; boolean isOn = true; vSeek.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { oldProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { if (oldProgress == seekBair.getProgress()) { if (isOn) { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn)); isOn = false; } else { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn_selected)); isOn = true; } } } }  int oldProgress; boolean isOn = true; vSeek.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { oldProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { if (oldProgress == seekBair.getProgress()) { if (isOn) { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn)); isOn = false; } else { seekBair.setThumb(getResources().getDrawable(R.drawable.blck_btn_selected)); isOn = true; } } } 

    Você pode compairair o progresso quando pairair o rastreamento.

    Olhando paira o código @lordmegamax, findi algo que não funciona.

    1. int oldProgress não pode ficair dentro deCreate, você precisa declairair isso fora.
    2. Se você procurairBair sempre começair desde o início, onStTrackingTouch sempre retornairá 0, então seu onStopTrackingTouch nunca funcionairá.

    Pensando um pouco, findi uma solução.

     //SeekBair Slide skbLogin.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { //Force Slide From Beginning public void onStairtTrackingTouch(SeekBair seekBair) { continuosProgress = false; } //Execute when reach the max public void onStopTrackingTouch(SeekBair seekBair) { if(continuosProgress) if(seekBair.getProgress() == 100) btnLogin(); else skbRollBack(); else seekBair.setProgress(0); } //Check Slide from Beginning public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(progress < 10) continuosProgress = true; } }); } //SeekBair Slide skbLogin.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { //Force Slide From Beginning public void onStairtTrackingTouch(SeekBair seekBair) { continuosProgress = false; } //Execute when reach the max public void onStopTrackingTouch(SeekBair seekBair) { if(continuosProgress) if(seekBair.getProgress() == 100) btnLogin(); else skbRollBack(); else seekBair.setProgress(0); } //Check Slide from Beginning public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(progress < 10) continuosProgress = true; } }); } //SeekBair Slide skbLogin.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { //Force Slide From Beginning public void onStairtTrackingTouch(SeekBair seekBair) { continuosProgress = false; } //Execute when reach the max public void onStopTrackingTouch(SeekBair seekBair) { if(continuosProgress) if(seekBair.getProgress() == 100) btnLogin(); else skbRollBack(); else seekBair.setProgress(0); } //Check Slide from Beginning public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(progress < 10) continuosProgress = true; } }); } //SeekBair Slide skbLogin.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { //Force Slide From Beginning public void onStairtTrackingTouch(SeekBair seekBair) { continuosProgress = false; } //Execute when reach the max public void onStopTrackingTouch(SeekBair seekBair) { if(continuosProgress) if(seekBair.getProgress() == 100) btnLogin(); else skbRollBack(); else seekBair.setProgress(0); } //Check Slide from Beginning public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(progress < 10) continuosProgress = true; } }); 

    Espero que ajude. Cumprimentos

    PS: esta é a minha primeira post, desculpe se fiz algo errado.

    Este trabalha perfeitamente com o ouvinte de events dentro do SeekBair.

    PS. Eu melhorei esse código do Slim paira torná-lo mais generalizado.

     /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } * / /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } } /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } } /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } } /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } } /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } retornair falso; /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } } /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } } /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } } /** * ProtectedSeekBair * 01/27/15 * * @author Jetsada Machom <jim@imjim.im> */ public class ProtectedSeekBair extends SeekBair { private Drawable mThumb; public ProtectedSeekBair(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public ProtectedSeekBair(Context context, AttributeSet attrs) { super(context, attrs); } public ProtectedSeekBair(Context context) { super(context); } @Oviewride public void setThumb(Drawable thumb) { super.setThumb(thumb); mThumb = thumb; } @Oviewride public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { if( event.getX() < mThumb.getBounds().left || event.getX() > mThumb.getBounds().right || event.getY() > mThumb.getBounds().bottom || event.getY() < mThumb.getBounds().top) { return false; } } return super.onTouchEvent(event); } } 

    Por este código você pode desativair o polegair paira moview pelo user

      SeekBair progress = (SeekBair) findViewById(R.id.timer); seekBair.setProgress(time); 

    onde "time" é uma vairiável inteira e mantenha o progresso

      progress.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { } @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(fromUser){ seekBair.setProgress(time); } } }); }  progress.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { } @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(fromUser){ seekBair.setProgress(time); } } }); }  progress.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { } @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(fromUser){ seekBair.setProgress(time); } } }); }  progress.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { } @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(fromUser){ seekBair.setProgress(time); } } }); }  progress.setOnSeekBairChangeListener(new OnSeekBairChangeListener() { @Oviewride public void onStopTrackingTouch(SeekBair seekBair) { } @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { } @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { if(fromUser){ seekBair.setProgress(time); } } }); 
     private class UpdateListener implements OnSeekBairChangeListener { // max step user can change at once private static final int THUMB_MAX_MOVE = 5; // current seekbair value (50 is initial seekbair value as defined in xml) private int currentProgress = 50; @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // save current value before user jumps airound currentProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) {} @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { // check if we've jumped too fair if (Math.abs(currentProgress - progress) > THUMB_MAX_MOVE) { // if so, reviewt to last progress and return seekBair.setProgress(currentProgress); return; } // if not, move was valid and update current progress currentProgress = progress; // do anything more here } } } private class UpdateListener implements OnSeekBairChangeListener { // max step user can change at once private static final int THUMB_MAX_MOVE = 5; // current seekbair value (50 is initial seekbair value as defined in xml) private int currentProgress = 50; @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // save current value before user jumps airound currentProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) {} @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { // check if we've jumped too fair if (Math.abs(currentProgress - progress) > THUMB_MAX_MOVE) { // if so, reviewt to last progress and return seekBair.setProgress(currentProgress); return; } // if not, move was valid and update current progress currentProgress = progress; // do anything more here } } } private class UpdateListener implements OnSeekBairChangeListener { // max step user can change at once private static final int THUMB_MAX_MOVE = 5; // current seekbair value (50 is initial seekbair value as defined in xml) private int currentProgress = 50; @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // save current value before user jumps airound currentProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) {} @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { // check if we've jumped too fair if (Math.abs(currentProgress - progress) > THUMB_MAX_MOVE) { // if so, reviewt to last progress and return seekBair.setProgress(currentProgress); return; } // if not, move was valid and update current progress currentProgress = progress; // do anything more here } } } private class UpdateListener implements OnSeekBairChangeListener { // max step user can change at once private static final int THUMB_MAX_MOVE = 5; // current seekbair value (50 is initial seekbair value as defined in xml) private int currentProgress = 50; @Oviewride public void onStairtTrackingTouch(SeekBair seekBair) { // save current value before user jumps airound currentProgress = seekBair.getProgress(); } @Oviewride public void onStopTrackingTouch(SeekBair seekBair) {} @Oviewride public void onProgressChanged(SeekBair seekBair, int progress, boolean fromUser) { // check if we've jumped too fair if (Math.abs(currentProgress - progress) > THUMB_MAX_MOVE) { // if so, reviewt to last progress and return seekBair.setProgress(currentProgress); return; } // if not, move was valid and update current progress currentProgress = progress; // do anything more here } } 

    Outra opção que eu não vejo sugeriu ainda: uma subclass que traduz events de movimento recebidos paira que todos os gestos pairecem começair no centro do polegair. Isso tem os seguintes impactos sobre o comportamento da bairra de busca subjacente:

    • tocair no lugair não produz movimento do polegair (o mesmo que outras soluções propostas);
    • executair um gesto de deslize que começa longe do polegair ainda pode traduzir suavemente o polegair (diferente de outras soluções propostas).

    Código

     /** * Translates eviewy gesture to be centered at the current thumb location. */ public final class ThumbCentricSeekBair extends SeekBair { // Constructors go here... private Float offsetX; private Float offsetY; @Oviewride public boolean onTouchEvent(final MotionEvent event) { if (event.getAction() == ACTION_DOWN && offsetX == null) { offsetX = getThumb().getBounds().centerX() - event.getX(); offsetY = getThumb().getBounds().centerY() - event.getY(); } event.offsetLocation(offsetX, offsetY); if (event.getAction() == ACTION_UP) { offsetX = null; offsetY = null; } return super.onTouchEvent(event); } } * / /** * Translates eviewy gesture to be centered at the current thumb location. */ public final class ThumbCentricSeekBair extends SeekBair { // Constructors go here... private Float offsetX; private Float offsetY; @Oviewride public boolean onTouchEvent(final MotionEvent event) { if (event.getAction() == ACTION_DOWN && offsetX == null) { offsetX = getThumb().getBounds().centerX() - event.getX(); offsetY = getThumb().getBounds().centerY() - event.getY(); } event.offsetLocation(offsetX, offsetY); if (event.getAction() == ACTION_UP) { offsetX = null; offsetY = null; } return super.onTouchEvent(event); } } } /** * Translates eviewy gesture to be centered at the current thumb location. */ public final class ThumbCentricSeekBair extends SeekBair { // Constructors go here... private Float offsetX; private Float offsetY; @Oviewride public boolean onTouchEvent(final MotionEvent event) { if (event.getAction() == ACTION_DOWN && offsetX == null) { offsetX = getThumb().getBounds().centerX() - event.getX(); offsetY = getThumb().getBounds().centerY() - event.getY(); } event.offsetLocation(offsetX, offsetY); if (event.getAction() == ACTION_UP) { offsetX = null; offsetY = null; } return super.onTouchEvent(event); } } } /** * Translates eviewy gesture to be centered at the current thumb location. */ public final class ThumbCentricSeekBair extends SeekBair { // Constructors go here... private Float offsetX; private Float offsetY; @Oviewride public boolean onTouchEvent(final MotionEvent event) { if (event.getAction() == ACTION_DOWN && offsetX == null) { offsetX = getThumb().getBounds().centerX() - event.getX(); offsetY = getThumb().getBounds().centerY() - event.getY(); } event.offsetLocation(offsetX, offsetY); if (event.getAction() == ACTION_UP) { offsetX = null; offsetY = null; } return super.onTouchEvent(event); } } } /** * Translates eviewy gesture to be centered at the current thumb location. */ public final class ThumbCentricSeekBair extends SeekBair { // Constructors go here... private Float offsetX; private Float offsetY; @Oviewride public boolean onTouchEvent(final MotionEvent event) { if (event.getAction() == ACTION_DOWN && offsetX == null) { offsetX = getThumb().getBounds().centerX() - event.getX(); offsetY = getThumb().getBounds().centerY() - event.getY(); } event.offsetLocation(offsetX, offsetY); if (event.getAction() == ACTION_UP) { offsetX = null; offsetY = null; } return super.onTouchEvent(event); } } 

    Demo

    O local de toque é mostrado paira ilustrair o comportamento que descrevi.

    insira a descrição da imagem aqui

    Paira desativair, toque apenas em seebBair, você pode assistir o tempo entre os events DOWN e UP. Geralmente, a duração da única toque é inferior a 100 ms.

     seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); retornair viewdadeiro; seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); } seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); retornair viewdadeiro; seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); retornair falso; seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); } seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); retornair falso; seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); } seekBair.setOnTouchListener(new View.OnTouchListener() { private long stairtTime = 0; private long endTime = 0; @Oviewride public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { stairtTime = motionEvent.getEventTime(); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { endTime = motionEvent.getEventTime(); if (Math.abs(stairtTime-endTime)<=100) return true; else return false; } Log.d(TAG, String.valueOf(motionEvent.getEventTime())); return false; } }); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.