I have a linear layout with a vertical orientation into which I insert several groups of views. One of them:
<LinearLayout android:id="@+id/addedit_updowncontrol" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/textView2" android:layout_marginBottom="5dp" android:orientation="horizontal"> <Button android:id="@+id/addedit_btndecrement" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_weight="0.1" android:text="-" /> <EditText android:id="@+id/addedit_txtQuantity" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="90dp" android:layout_weight="0.4" android:layout_alignParentTop="true" android:inputType="numberDecimal" /> <Button android:id="@+id/addedit_btnIncrement" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_weight="0.1" android:layout_toLeftOf="@+id/addedit_units" android:text="+" /> <Spinner android:id="@+id/addedit_units" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.4" android:layout_alignParentTop="true" android:layout_alignParentRight="true" /> </LinearLayout>
This gives me an idea that looks like this (sorry for the link, I would like a better way). This is unacceptable because the button does not align with EditText.
I tried switching to RelativeLayout, which gives me something like this . This is unacceptable because the two buttons (-) and (+) do not have the same width.
I assume that I am trying to achieve: (1) The baseline of the button is aligned with the other controls in the line. (2) Two buttons have the same width.
It seems I can achieve (1) with RelativeLayout and (2) with LinearLayout . But not both.
Can anybody help me?
source share