Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 63

Don
Aspiring developer
Profile
Posts: 40
Reg: Aug 10, 2012
moving within e...
2,550
08/28/12 08:33 AM (11 years ago)

MenuListSimple : how to have rowheights dynamically adapt to text content?

Hey everyone, I have spent hours trying to do that myself and hope somebody might stop by before I eat my laptop!!! :) I am using BT v2, android nexus S What I currently have: In my menulistsimple screen, I want to display, say, 100 rows, each containing between 2 to 4 lines of text. I want the text of each row to be displayed entirely. So, I have already added android:singleLine="false" in the textview paragraph of menu_list_rowsimple.xml. It does display several lines of text. BUT the text is cut out when there is too many lines in a row. All the rows have the exact same height. The height doesn't change according to the text content. I could change manually the rowheight in XML to make it bigger to take care of the 4lines rows, but then if there is a row with only 2 lines of text, it is not gonna look as I want. What I want to achieve: I would like the heights of each row to nicely adapt so that: - if there is a text of 2 lines in a row, the row height will display only the 2 rows and no extra space - if there is a text of 4 lines in a row, the row height automatically grows to display 100% of the text and doesn't cut it out. from my research on the web, it looks like it cannot be solved only in XML and requires java code, which I am super beginner at. Also it's confusing to me where exactly to look at and what to change in the profusion of files and child/parents hierarchy (I don't blame BT for that of course, it's just because I am a beginner :) Thanks a lot if you have an idea to help.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
08/28/12 11:34 AM (11 years ago)
Haven't got eclipse to hand, so I can't try it, but have you tried, in the textView, something like: android:height="wrap_content" or android:height="fill_parent"
 
Don
Aspiring developer
Profile
Posts: 40
Reg: Aug 10, 2012
moving within e...
2,550
like
08/28/12 01:55 PM (11 years ago)
Thanks for replying. Unfortunately this is not a valid parameter. I do use a layout_height="wrap_content" and have tried every combination switching "wrap_content" and "fill_parent" in the textview. Any other idea?
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
08/28/12 02:54 PM (11 years ago)
Damn. This should be fairly straightforward! Maybe this list of params will help? http://developer.android.com/guide/topics/resources/layout-resource.html and stackoverflow.com is a good resource. Height should be used in conjunction with width, if that's any help...
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.