I have a Seekbar that works perfectly except for one part. I want to adjust the height of a textView depending on the Seekbar value.
I'm using this code to adjust the height of the textView:
SeekBar sb1 = (SeekBar)findViewById(R.id.telecom_years_bar);
sb1.setMax(14);
sb1.setProgress(9);
sb1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar sb1, int progress, boolean fromUser) {
progress = progress + 1;
TextView RedInitialBar = (TextView) findViewById(R.id.initial_bar1);
RedInitialBar.getLayoutParams().height = (progress);
I have similar code on create and it works fine when the activity first loads, but adjusting the Seekbar doesn't update the height of the textView. All of the other calculations I have tied to that Seekbar recalculate perfectly when it is adjusted. What am I missing?
When you change the height or any dimensions of a View after it's been laid out onto the screen, it must be laid out again. Try calling requestLayout() on the TextView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With