I am trying to set height of an image view and a Button to be automatically resized for different devices . I want to show the button below the imageview whatever the height of the image is.
I am trying this code :
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/send_btn"
android:layout_bellow="imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Thanks in advance
I suppose, you are using LinerLayout, with android:orientantion="vertical". I'd use a layout_weight attribute, as follows:
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/send_btn"
android:layout_bellow="imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
It will automatically fill all the upper part with the image view.
By using layout_weight="1" and layout_height="wrap_content" in ImageView, you tell Android that ImageView is "important" and must fill in all the remaining space.