android - Place dynamic view between two views vertically -
here problem: want place view dynamic height calculated @ runtime according width (lets call center view) between 2 views. tricky part top , bottom views should adapt height fit space left after center view measurement , layout, , height shouldn't less minheight. managed put 3 views in vertical linear layout, top , bottom have weight = 1 , center view fixed height, when center view height becomes bigger value covers top , bottom views , minheight param ignored. here part of layout, hope helps:
<linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:id="@+id/toplinearlayout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:minheight="84dp" android:orientation="horizontal" > <!-- content here --> </linearlayout> <view android:id="@+id/centerview" android:layout_width="match_parent" android:layout_height="300dp" /> <linearlayout android:id="@+id/bottomlinearlayout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:minheight="62dp" android:orientation="horizontal" > <!-- content here --> </linearlayout> </linearlayout>
solved restricting height of center view windowheight - (minheight1 + minheight2) minheight1 , minheight2 known constants. if height less windowheight - (minheight1 + minheight2) linear layout fine
Comments
Post a Comment