Reputation: 3526
I am trying to make a layout
where there are a LinearLayout
and inside it I want a FrameLayout
and a button
.
I want the button
to use the bottom of the linearlayout
and to use the maximum width and the enough height for the button, using wrap content.
The other component, the FrameLayout
I want to use it the remaining part of the screen.
How can I do it?
Here it the layout so far..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button
android:id="@+id/button_capture"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="snapIt"
android:text="@string/Capture" />
</LinearLayout>
Is not showing the button :s
Thanks alot in advance ;)
Upvotes: 0
Views: 749
Reputation: 55
i am just trying to make these layout, after compare my layout code and your layout code, i find a different code, there is in my code. Did you missing it or just move it away cause it useless from the layout code ?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<FrameLayout
android:id="@id/flayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world">
</FrameLayout>
</LinearLayout>
Upvotes: 0
Reputation: 4348
use the following xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button_capture"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="snapIt"
android:layout_alignParentBottom="true"
android:text="capture" />
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button_capture"
/>
</RelativeLayout>
Upvotes: 1
Reputation: 1095
Better to work out with relative layout with button aligned to parent bottom and your frame layout above it occupying the rest space of the screen.Like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/button_capture"/>
<Button
android:id="@+id/button_capture"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="snapIt"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
Upvotes: 1