I have a
ListView which would usually only display 1-3 items at runtime, but Android Studio fills it with 24, making it overtake the whole layout. If I want to see the rest of the layout I have to either comment it out or set its visibility to gone. Is there a way I can make Android Studio only render a couple of items so my other views in the layout will be visible in the designer?
I was facing the same issue and I solved it by adding this to the ListView definition:
If you’re using a RecyclerView, you could do it much better:
Both arguments are only applied in the Android Studio preview, not in the app itself, see https://developer.android.com/studio/write/tool-attributes.
I’m assuming right now your ListView has a height that wraps content, which means it will be as long as it can to display everything. If you want to limit it, it you can give it a specific dp height or you can give it a gravity (to make it say half the screen).