for practice I am writing an activity that takes a string from a local DB and puts it into a listView. However the string’s are of different length, ranging from a couple of characters, to a couple of sentences. Write now I can take them and place them in a listView but, not all of the strings fit. I was curious if/how you can dynamically choose the height of each part of the list view so that the entire string can fit in it.
Share
Just make sure your list item layout is using
wrap_contentfor itslayout_heightattribute. If you’re using a fixed height, it won’t scale to fit larger strings. If you want the lists a specific size except for in situations as mentioned, you can also add aandroid:minHeightattribute as well with the dimension you want as standard.Also, make sure your
TextViewis set to multiline (attributeandroid:singleLine="false").