【发布时间】:2014-02-25 21:11:00
【问题描述】:
一段时间以来,我一直在用这个把我的头撞到墙上。基本上我的应用程序显示了一个充满屏幕的相机预览,当用户点击预览时,它会捕获一个图像(试图通过一个透明的图像按钮来做到这一点。在屏幕底部我想要另一个图像按钮,这次它会停止应用程序正在进行的录制。
这是我的活动布局
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<ImageButton
android:id="@+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/capture"
android:src="@null" />
</FrameLayout>
<ImageButton
android:id="@+id/stopRecording"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="bottom|center"
android:layout_marginBottom="50dp"
android:background="@null"
android:contentDescription="@string/stopRec"
android:onClick="moveToUpload"
android:scaleType="fitCenter"
android:src="@drawable/rec_gray" />
</FrameLayout>
我尝试使用 FrameLayouts,因为它们允许覆盖。
唯一不变的是 CameraPreview 必须是 FrameLayout。
如有任何帮助,请更正此代码,
谢谢。
【问题讨论】:
标签: android android-camera imagebutton