android - Positioning elements with percentage -
i want put, example, 9 elements (others layouts or imageviews) in rows of three. in html put each div 33.3% height/width , word.
how can in android layout xml? can't find info percentage or positioning that...
thanks folks!
you can use either gridview or simple linearlayout 3 item each row layout weight 1 each column. unlike gridview (or listview), if use linearlayout wont reused when view draw outside screen. here simple using simple linearlayout:
<linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <linearlayout android:id="@+id/row1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <button android:id="@+id/location1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> <button android:id="@+id/location2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/> <button android:id="@+id/location3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/> </linearlayout> <linearlayout android:id="@+id/row2" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <button android:id="@+id/location4" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> <button android:id="@+id/location5" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/> <button android:id="@+id/location6" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/> </linearlayout> </linearlayout>
Comments
Post a Comment