2017-06-03 31 views
0

我想我的活動背景是相機(後退)視圖,我到目前爲止試圖添加一個surfaceView,但沒有運氣,我發現的教程是打開相機應用程序。 P.S-我想在SurfaceView/Camera上添加更多的資源。 & 我不想點擊圖片只預覽 由於我沒有任何代碼顯示,因爲它們不是我需要的,所以這裏是next best thing,雖然它可能沒有必要。添加一個相機預覽

回答

0

你有沒有試過類似的東西?

<?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"> 


     <SurfaceView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <!--views on top should come after the surfaceview, 
    at the same level in the view heirarchy. 
    this gives them a higher z-index (i.e. drawn afterwards) 
    ... you could also use a RelativeLayout as the root view --> 

     <ImageView 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_gravity="center"/> 



</FrameLayout> 
+0

我已經應用了代碼,我會盡快讓你知道,而且這個簡短代碼會創建一個沒有任何java類編程的預覽? – Anonymous

+0

順便說一句,它只是顯示一個黑屏 – Anonymous

+0

不,對不起,這是一個佈局的例子,你必須在onCreate()的活動中充氣,以便你可以將視圖放在相機背景上。表面視圖需要顯示從相機接收到的幀。也許這個教程可能會有所幫助:http://blog.rhesoft.com/2015/04/02/tutorial-how-to-use-camera-with-android-and-android-studio/ – maturecheese