一段時間後,我的頭從牆上撞過。基本上我的應用程序顯示了一個填充屏幕的相機預覽,當用戶點擊預覽時它會捕捉一個圖像(試圖通過透明的圖像按鈕來做到這一點)。在屏幕的底部,我想要另一個圖像按鈕,這次它會停止應用程序在做記錄。創建水龍頭捕捉透明的ImageButton通過CameraPreview
這裏是我的活動佈局
<?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。
任何幫助表示讚賞糾正這段代碼,
謝謝。
你是上帝。非常感謝你!!!!! – allyjweir