Show 3 scrollable ListViews of equal height in Android Layout -
i trying show 3 different vertical sections in android layout on 1 screen, each taking 1 third of screen, 1 on top, 1 in middle, , 1 on bottom. each section has textview , listview, , listviews can scroll can see items, overall page not move. have tried putting each textview , listview in linearlayout , setting height of each linearlayout 1 third total height of screen, first listview shows items in it, taking of screen, , other sections pushed down. tried using layout_weights, reason did not work. (edit: setting layout_weight="1" ended working, i'm not sure did wrong first time) how can make work, or there better way go this?
<linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <listview android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="#ff0000"/> <listview android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="#00ff00"> <listview android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="#0000ff"> </linearlayout> this give 3 equally wide columns: make rows, change orientation vertical , swap values of layout_height , layout_width each listview. if need add textviews, you'll have make each listview in code either relativelayout linearlayout or framelayout, using same width/height/weight , arranging listview , textview inside taste. efficiently, use framelayout , use margin on listview offset textview. can place textview relative listview inside framelayout using layout_gravity in textview.
ie (swapping first "column"):
<framelayout android:orientation="vertical" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="#ff0000"> <textview android:text="column!" android:background="#3eff0000" android:layout_height="40dp" android:layout_width="match_parent"> <listview android:layout_margintop="48dp" android:layout_height="match_parent" android:layout_width="match_parent" android:background="#8aff0000"/> </framelayout>
Comments
Post a Comment