Hi, useful members of stackoverflow,
I am trying to accomplish what seems like a simple layout in Android activity, but I can't get it to work using only wrap_content and fill_parent / match_parent.
Image to give a general idea of โโthe problem: http://i89.photobucket.com/albums/k207/cephron/Layout_quandary.png
In a vertical LinearLayout, I have an ImageView at the top of a child layout containing buttons and stuff. I would like the ImageView to be expanded to make the image as large as possible (i.e. to fill the width of the screen), without taking up more vertical space than is necessary to achieve this (i.e. I want the ImageView to touch the top of the screen, with buttons and stuff touch the bottom of the image). I can't make this happen using wrap_content and fill_parent, and all of my gravity mess seems to change nothing. I had to turn on the scales only so that the image did not completely knock everything off the screen.
I would like to publish the correct code, but - the noob that I am - I spent about 20 minutes trying to get it to work with Stackoverflow code formatting, and parts of it will not appear.
So, here is my code, distorted enough that it is not recognized by selectively deleting parts of it:
[LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal"] [ImageView android:id="@+id/door_detail_video_frame" android:src="@drawable/door_closed_256" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"/] [LinearLayout android:id="@+id/door_detail_control_area" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0"] [ImageView android:id="@+id/door_detail_status_frame" android:src="@drawable/door_closed_locked_67" android:layout_width="wrap_content" android:layout_height="fill_parent"/] [LinearLayout android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent"] [Button android:id="@+id/door_detail_override_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/door_detail_override_button_text"/] [Button android:id="@+id/door_detail_camera_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/door_detail_camera_button_text"/] [/LinearLayout] [/LinearLayout] [/LinearLayout]
I believe that the only relevant parts are the first LinearLayout and ImageView, but the material for nested layouts (corresponding to โbuttons and the likeโ) is included for completeness.
Is there a way to achieve the desired layout formatting?
Thanks in advance for your help!
source share