Component Alignment in RelativeLayout

| --Button 1-- |

| -Button 2- |

Using RelativeLayout, as I align the width of button 2 so that it matches the width of button 1.

+4
source share
3 answers
<Button android:id="@+id/A" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dip" android:textSize="14sp" android:text="--Button1--" /> <Button android:id="@+id/B" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/A" android:gravity="center" android:text="Button2" android:layout_alignLeft="@id/A" android:layout_alignRight="@id/A" android:textSize="14sp" /> 

Try to do it inside RelativeLayout

+5
source

What you are looking for should be layout_alignRight . This will align your right edge of the View with the right edge of the snap.

+1
source

If you want button 2 to depend on button 1, then there is no way (as far as I know) to do this. However, if you are developing a dynamic layout, you can do this programmatically.

0
source

All Articles