Is there a way to find the height of the ListView element currently displayed in the list without installing it in the layout XML files?
I tried
View listItem = listAdapter.getView(currentIndex, null, listView); listItem.measure(MeasureSpec.EXACTLY, MeasureSpec.UNSPECIFIED); int itemHeight = listItem.getMeasuredHeight();
and although it worked at first, it decided to throw a Null Pointer exception during a call to measure () after starting a new emulator session.
What I'm trying to do is to have an item in a short list (only 2 or 3 full items are visible) to be centered when the program selects.
user1018979
source share