tags:

views:

57

answers:

1

Is there a way to center an image horizontally based on another image? Could be from xml or coded.

For example one button on top and another button below (i.e. android:layout_below="@+id/button1"), but centered horizontally based on the first one.

A: 

Is the second image the same size or smaller than the first? If so, you can align the left and right sides, and specify a centred fit...

<ImageView
    android:id="@+id/secondImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/firstImage"
    android:layout_alignLeft="@id/firstImage"
    android:layout_alignRight="@id/firstImage"
    android:scaleType="center" />
Andy
Nice, it does work when its smaller and I would never thought of aligning both sides. Unfortunately it "cuts" the image if its bigger :/
Bumper