开发者

Android Layout Questions

开发者 https://www.devze.com 2023-03-29 17:07 出处:网络
I tried to create an edittext textbox that will compute the width a开发者_C百科nd height automatically by using the WRAP_CONTENT way. However, at some point of time I will need the actual height of th

I tried to create an edittext textbox that will compute the width a开发者_C百科nd height automatically by using the WRAP_CONTENT way. However, at some point of time I will need the actual height of the edit text, but I tried using layout params and getWidth(), getHeight(), I am not being returned with the values I will require.

Anyone have got any idea how can I go about this?


You need to call view.layout() and then view.measure() in order for those values to be available to you prior to actual "layout" and display on the screen.

You need to be careful with wrap_content, though, because if your content is not already present in the view, it will not return the values you're looking for.

Hope this helps.

0

精彩评论

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

关注公众号