Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set height of one layout component to the same height of another component?

How can I set one layout components height to the same as another component: example: Can I set android:layout_height="@+id/info_box.height" or do something similar?

I want the height of the ImageView to match that of my LinearLayout

ImageView android:id="@+id/border"
  android:src="@drawable/frame"
android:layout_below="@+id/title"
android:layout_width="fill_parent"
android:layout_height="????"    
android:scaleType="fitXY" 
android:drawingCacheQuality="auto"
/>

<LinearLayout
android:id="@+id/info_box"
android:orientation="vertical"
android:layout_below="@+id/title"
android:background="@layout/my_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
... other stuff . .
 </LinearLayout>
like image 259
steve Avatar asked Jan 13 '11 20:01

steve


1 Answers

The only way to achieve this is to have the two views be part of the same container. A LinearLayout or RelativeLayout are usually well suited for this. You could also achieve this through code.

like image 196
Romain Guy Avatar answered Nov 02 '22 06:11

Romain Guy