I need to have a video preview(on a Surface) and a TextView and a few buttons(at the bottom of the screen)
Currently, my preview’s height is large but it’s narrow and at the far left at the screen and the TextView is not visible.
The buttons are placed at the bottom as I require.
How do I make the preview’s width large as well and the TextView visible?
Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android Recorder"
/>
<SurfaceView android:id="@+id/camsurface"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1" />
<TextView
android:id="@+id/recording_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" 00:00"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button android:id="@+id/btn_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"/>
<Button android:id="@+id/btn_record"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Record" />
Your “preview is very small” is very small because you have it set for 140px square, hard-wired in your layout.
Either take advantage of
android:layout_weightwithLinearLayout, or useRelativeLayout, to make yourSurfaceViewtake as much space as is available.For example, here is a layout with a
Buttonat the bottom and aWebViewfilling up all remaining space: