开发者

Changing the height of an existing, visible TextView

开发者 https://www.devze.com 2022-12-23 06:14 出处:网络
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 take

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, e开发者_Go百科ven 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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消