tags:

views:

74

answers:

1

Hi I'd like to programatically increase the height allocated to a TextView, and have the activity layout redrawn accordingly (the text view has a maximum height until the user clicks it, then it takes up all height required, wrap_content).

setHeight() isn't working, even coupled with invalidate() or postInvalidate(). I am able to change the contents of the TextBox with setText() but it isn't altering the existing specified height.

Android 1.5 under the 1.6 SDK.

+2  A: 

Didn't test that , but try to create new Layout params and assign it to a view This is for a button, but idea is same.

  LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            params.weight = 0;
            shareBtn.setPadding(50, 0, 50, 0);
            shareBtn.setLayoutParams(params);
Alex Volovoy
Many thanks Alex. It works. I did try something similar but was getting exceptions inside Android layout stuff ... looking at what I wrote, the problem was I was using the wrong LayoutParams class. There is more than one.
Jim Blackler