开发者

Changing the height of an existing, visible TextView

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜