tags:

views:

26

answers:

1

Hello

I was wondering if there is a way for placing a view to the right side of another view and centering it vertically on the second views height. In know this can be done using a LinearLayout, but for other reasons the 2 views must be part of the same RelativeLayout.

Thanks a lot

A: 
<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
    <View android:id="@+id/view1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
    <View
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/view1"
        android:layout_centerVertical="true"
        />
</RelativeLayout>

Something like that?

Felix
Not really. The second view must be centered on the first view's height, not on the parent's height. And I can't center both of them in the pa rent, because the parent must be as large as the screen, and the views must be placed in the upper part.
Gratzi
Ah, I see. Then your only option is to use a second `RelativeLayout` that holds these two views and that is aligned to the top of the parent `RelativeLayout`.
Felix