Is possible to start seekBar OnSeekBarChangeListener from other view( different than my seekBar)?
I have a SeekBar(seekBar1) on my layout with a small height (3dp). Because of it's small height is hard to select that view and I want to implement an other way to update the progress for my seek view. For to do that I think at something like that: I have to put an other bigger and invisible(android:background = "#00000000"
) seekBar(seekBar2) under my small seekBar1, I set the onSeekBarChangeListener
for seekBar2, and everytime when I touch the seekBar2 and onSeekBarChange()
is called I will update the progress for seekBar1.
I want to ask if is posible to do that in a better way?
This is my code:
seekBarSecond.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) { try {
musicService.seekTo(seekBar.getProgress());
seekBar.setProgress(seekBarSecond开发者_运维问答.getProgress());
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
}
});
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
public void onStopTrackingTouch(SeekBar seekBar) {
try {
musicService.seekTo(seekBar.getProgress());
} catch (RemoteException e) {
e.printStackTrace();
}
}
public void onStartTrackingTouch(SeekBar seekBar){
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser){
}
});
Thank you!
I had the exact same problem, and tried your solution first... it works, but you can indeed do better : just specify padding. With padding (you'll probably only need top and bottom padding) the touch zone is actually the size of the widget, including the padding. So adding 16 pixels of top and bottom padding will add 32 pixels to the SeekBar's touch boundaries.
Hope that helps !
精彩评论