Android Image Is Seen/not Seen When Orientation Is Changed
I'm having some problems with ScrollView and an ImageView. What I want is: I have an ImageView set always at the top of the screen. Then, I have an ScrollView where go all elements
Solution 1:
The solution I've found, looking at that question, is:
Create that function:
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
// pre-condition
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
}
and call it with my ListView. Only one Scroll
(the one of ScrollView
) is seen and used.
Post a Comment for "Android Image Is Seen/not Seen When Orientation Is Changed"