0

In my xml,

<LinearLayout
                android:id="@+id/row2B"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignBottom="@+id/row2A"
                android:layout_alignParentRight="true"
                android:layout_alignTop="@+id/row2A"
                android:orientation="vertical"
                android:padding="@dimen/dp10"
                android:paddingBottom="2dp"
                android:splitMotionEvents="false"
                android:weightSum="6" >

                <ImageButton
                    android:id="@+id/btn_amend_all"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="5dp"
                    android:layout_weight="1"
                    android:background="@drawable/transparent_btn"
                    android:scaleType="center"
                    android:splitMotionEvents="false" />

                <ImageButton
                    android:id="@+id/btn_amend_list1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/dp2"
                    android:layout_weight="1"
                    android:background="@drawable/white_btn_border_nil"
                    android:scaleType="center"
                    android:splitMotionEvents="false"
                    android:src="@drawable/btn_edit_selector" />

                <ImageButton
                    android:id="@+id/btn_amend_list2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/dp2"
                    android:layout_weight="1"
                    android:background="@drawable/white_btn_border_nil"
                    android:scaleType="center"
                    android:splitMotionEvents="false"
                    android:src="@drawable/btn_edit_selector" />

                <ImageButton
                    android:id="@+id/btn_amend_list3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/dp2"
                    android:layout_weight="1"
                    android:background="@drawable/white_btn_border_nil"
                    android:scaleType="center"
                    android:splitMotionEvents="false"
                    android:src="@drawable/btn_edit_selector" />

                <ImageButton
                    android:id="@+id/btn_amend_list4"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/dp2"
                    android:layout_weight="1"
                    android:background="@drawable/white_btn_border_nil"
                    android:scaleType="center"
                    android:splitMotionEvents="false"
                    android:src="@drawable/btn_edit_selector" />

                <ImageButton
                    android:id="@+id/btn_amend_list5"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/dp2"
                    android:layout_weight="1"
                    android:background="@drawable/white_btn_border_nil"
                    android:scaleType="center"
                    android:splitMotionEvents="false"
                    android:src="@drawable/btn_edit_selector" />
            </LinearLayout>

Screenshot:

enter image description here

on the left is a RadioGroup inside row2A, and the code is row2B, alignTop and bottom of row2A.

Question:

Referencing to What is android:weightSum in android, and how does it work?, I would like to have the 6 buttons spread equally in height, but why the above cannot achieve the purposes?

Thanks in advance!

Community
  • 1
  • 1
pearmak
  • 4,979
  • 15
  • 64
  • 122

1 Answers1

1

use

android:layout_height="0dp" for all ImageButton.

Amit Gupta
  • 8,914
  • 1
  • 25
  • 33
  • thanks for your reply....it still looks like wrap_content and packing with each other at top of the linearlayout, instead of pulling evenly distributed – pearmak Sep 10 '14 at 04:40
  • @pearmak can you post the screenshot that you want to achieve as well as whole layout. – Amit Gupta Sep 10 '14 at 04:45