android - 4 rows of Buttons in LinearLayout fill screen width -
i have vertical linearlayout
4 horizontal linearlayouts
. each horizontal layout contains 4 buttons
. want buttons
in each horizontal linearlayout
fill screen width evenly. looks this:
the first button
of each row takes width , other 3 buttons
per row not visible. know how can fix this?
<linearlayout android:id = "@+id/ll_screen_bttns" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="20dp" android:orientation="vertical" > <linearlayout android:id="@+id/ll1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight = "1"> <button android:id="@+id/button0" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0"/ /> <button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button2" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button3" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> </linearlayout> <linearlayout android:id="@+id/ll2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight = "1"> <button android:id="@+id/button4" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button5" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button6" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button7" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> </linearlayout> <linearlayout android:id="@+id/ll3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight = "1"> <button android:id="@+id/button8" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button9" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button10" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button11" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> </linearlayout> <linearlayout android:id="@+id/ll4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight = "1"> <button android:id="@+id/button12" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button13" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button14" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> <button android:id="@+id/button15" android:layout_width="fill_parent" android:layout_height="@dimen/size" android:background="@drawable/button" android:onclick="buttononclick" android:tag="0" /> </linearlayout> </linearlayout>
abstract xml:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <button android:layout_width="0dp" android:layout_height="@dimen/size" android:layout_weight="1" /> <button android:layout_width="0dp" android:layout_height="@dimen/size" android:layout_weight="1" /> <button android:layout_width="0dp" android:layout_height="@dimen/size" android:layout_weight="1" /> <button android:layout_width="0dp" android:layout_height="@dimen/size" android:layout_weight="1" /> </linearlayout> . . . </linearlayout>
Comments
Post a Comment