I simply dragged and dropped the button on Camera Preview Frame but the button is not visible when I execute the app on the device, I do not see the button. Please help to resolve this issue. I wan to add a Flash button on the camera preview. Here is the XML code.
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.05" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/flash_button" />
</FrameLayout>
<Button
android:id="@+id/button_capture"
android:text="@string/capture_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
I think you need to change the LinearLayout
to RelativeLayout
.
Here's the working XML that I'm using:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<FrameLayout
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/ind" >
</FrameLayout>
<Button
android:id="@+id/button_switchcam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_switch_button"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/btn_capture_button"
tools:ignore="HardcodedText" />
</RelativeLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.