开发者

how to set height of textview according to its content -[android]

开发者 https://www.devze.com 2023-01-14 09:01 出处:网络
i have a message,its content is not fixed. users message should be displayed in this textview. when i give a static message it displays in multiline, but when i use 开发者_C百科this through my code

i have a message,its content is not fixed. users message should be displayed in this textview. when i give a static message it displays in multiline, but when i use 开发者_C百科this through my code it shows only online. It do not get wrapped.

i use inflater in code, used getter/setter to set its text

pls help, thanks


You can set the lines of text to display with android:lines, or set a minimum and maximum number of lines with android:minLines and android:maxLines.

android:ellipsize would kick in only with a limited size, so if the text view is to grow to its content, it would not be needed, unless somehow constrained by the layout.

I also see you are using both layout_weight and layout_below/toRightOf. The first is available only in LinearLayout, the latter in RelativeLayout, so one of them should go, depending on which layout you are actually using.

0

精彩评论

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

关注公众号