I have a view with multiple vertical seekbar. I am drawing text on thumb and I want to display floating text-box above thumb while progress is changing.
We are able to display the text on top of thumb which floats while progress changes. OnStopTracking/on taking finger off from thumb floating text should not be visible.
I have added seekbar dynamically. Please find attached screenshot for how I want to implement.
Take a look at code :
Implementation of multiple seekbar :
for (int i = 0; i <= undertimearray.length - 1; i++) {
LayoutInflater layoutInfralte = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View inflatedView = layoutInfralte.inflate(R.layout.element_sliderandtext, ll_rightside, false);
TextView submittedByTextView = (TextView) inflatedView.findViewById(R.id.txt_underseekbar);
submittedByTextView.setText(undertimearray[i]);
//rl_seekbarandtext=(RelativeLayout)inflatedView. findViewById(R.id.rl_seekbarandtext);
myseekbar = (TextThumbSeekBar) inflatedView.findViewById(R.id.myseekbar);
tvProgress = (TextView) inflatedView.findViewById(R.id.tv_progress);
myseekbar.setMax(50);
ll_tempvalues.post(new Runnable() {
@Override
public void run() {
height = ll_tempvalues.getHeight();
// Log.e("TAG", "TAG" + "=height=" + height);
}
});
ll_rightside.addView(inflatedView);
}
Below is what we have tried to achieve displaying floating text above the thumb:
myseekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
final RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
p.addRule(RelativeLayout.ALIGN_RIGHT, seekBar.getId());
Rect thumbRect = myseekbar.getSeekBarThumb().getBounds();
Log.v("TAG", "ThumbRect Region : " + thumbRect.centerX());
p.setMargins(0, thumbRect.centerY() *12, 0, 0);
// tvProgress.setPadding(thumbRect.centerY() * 2, 0, 0, 0);
tvProgress.setVisibility(View.VISIBLE);
tvProgress.setLayoutParams(p);
//tvProgress.setY(progress * 10);
tvProgress.setText(String.valueOf(progress));
tvProgress.invalidate();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar)
{
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
tvProgress.setVisibility(View.GONE);
}
});
The issue we are facing is onStopTrackingTouch is not being called and due to this the progress text is not hiding. We are also not getting any status in ACTION_CANCEL inside onTouchEvent listener.
I took help of link for thumb and vertical seekbar : [Thumb link and added canvas.rotate(-90); canvas.translate(-getHeight(), 0);] for vertical seekbar1