What am I trying to do?
Activity starts with a ImageView
taking the upper 9/10 of the screen, and a ListView
the remaining bottom 1/10:
As more items added to the ListView
, the ratio changes, ListView
getting 1/10 more of the screen for each item, and ImageView
shrinks respectively, up to 50:50 ratio (adding more items after that keeps the ratio fixed) :
What I already know:
Best practice of statically dividing the screen, is using LinearLayout
attribute android:weightSum
(and View
's android:layout_weight
). It should be possible to it dynamically as well using AbsListView.LayoutParams
, combined with registering a callback somewhere in ArrayAdapter
. However, it fills like an abuse of a static feature (weight). Moreover, I'd prefer to do the transition between to ratios continuously (using Property Animation).
Questions:
Should I prefer using
getWindowManager() .getDefaultDisplay().getHieght();
once, and calculating ratio dynamically as desired?As for ratio updating callback, are there any option other than
ArrayAdapter.registerDataSetObserver()
?