2015-04-01 31 views
1

我有一些相機預覽(在FrameLayout中)的麻煩。 我要實現的是這樣的:Android:在相機預覽中顯示前景(和視圖),以便讓舊相機背面看

https://lh4.ggpht.com/aFPHmlYNaSAAJV2er2inD9dlXS61Sj-V1qyYeCpfgMCPY18kgdQEdIOyWkaXOlWeAkM=h900-rw或本:https://lh4.ggpht.com/_OkN-O2mb3s4VO6QoSj15cTdzTBic_Ji8-ZGg16PmvfFUNWpQHfaZuN6ofwPWOHhr34=h900-rw

但到目前爲止,所有我能做到: - 在一個FrameLayout裏 全屏預覽 - 一個小預覽放錯了地方(我希望它水平居中,並在40 DP頂部)

這是到目前爲止我的佈局:

<FrameLayout 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" android:background="@drawable/background_app_photo_transparent" tools:context="jmf.net.testsapp.CameraActivity" > <FrameLayout android:layout_width="320dp" android:layout_height="240dp" android:layout_gravity="center_horizontal" android:layout_marginTop="40dp" android:id="@+id/master_layout" /> </FrameLayout>

第一個FrameLayout是我把九個補丁繪製的地方,它必須恢復一些相機預覽。 第二個FrameLayout(id/master_layout)是我創建一個SurfaceView來顯示相機預覽的地方。

但是,當我嘗試這個,我已經在左下角的相機預覽。

所以我想我開始不好。

這是我的問題:如何管理佈局和相機預覽,以便在下面的圖片中有類似的內容?

+0

歡迎來到Stack Overflow!很高興看到你找到你的答案。你應該接受解決這個問題的答案,即使它是你自己的答案,而不是在這個題目上加上「解決方案」,這裏完全沒問題。 – 2015-04-02 13:37:26

+1

完成了。謝謝。 – 2015-04-05 17:13:34

回答

1

好的,我找到了一種方法。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
android:columnCount="3" 
android:rowCount="3"> 


<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="40dp" 
    android:id="@+id/imageView2" 
    android:background="@drawable/slice_0_0" 
    android:layout_gravity="fill" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_above="@+id/imageView5" 
    android:layout_toLeftOf="@+id/imageView3" 
    android:layout_toStartOf="@+id/imageView3" /> 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="40dp" 
    android:id="@+id/imageView3" 
    android:background="@drawable/slice_0_1" 
    android:layout_gravity="fill" 
    android:layout_alignParentTop="true" 
    android:layout_toLeftOf="@+id/imageView6" 
    android:layout_toRightOf="@+id/imageView5" 
    android:layout_toEndOf="@+id/imageView5" /> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="40dp" 
    android:id="@+id/imageView4" 
    android:background="@drawable/slice_0_2" 
    android:layout_gravity="fill" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentRight="true" 
    android:layout_above="@+id/imageView6" 
    android:layout_toRightOf="@+id/imageView3" 
    android:layout_toEndOf="@+id/imageView3" /> 


<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/imageView5" 
    android:background="@drawable/slice_1_0" 
    android:layout_gravity="fill" 
    android:layout_below="@+id/imageView3" 
    android:layout_toLeftOf="@+id/master_layout" 
    android:layout_toStartOf="@+id/master_layout" 
    android:layout_alignBottom="@+id/master_layout" /> 

<FrameLayout 
    android:layout_width="320dp" 
    android:layout_height="240dp" 
    android:layout_gravity="center_horizontal" 
    android:id="@+id/master_layout" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="40dp" 
    /> 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/imageView6" 
    android:background="@drawable/slice_1_2" 
    android:layout_gravity="fill" 
    android:layout_toRightOf="@+id/master_layout" 
    android:layout_alignParentRight="true" 
    android:layout_below="@+id/imageView3" 
    android:layout_alignBottom="@+id/master_layout" /> 


<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/imageView7" 
    android:background="@drawable/slice_2_0" 
    android:layout_gravity="fill" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_alignBottom="@+id/imageView9" 
    android:layout_toLeftOf="@+id/imageView3" 
    android:layout_toStartOf="@+id/imageView3" 
    android:layout_below="@+id/imageView5" /> 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/imageView8" 
    android:background="@drawable/slice_2_1" 
    android:layout_gravity="fill" 
    android:layout_toLeftOf="@+id/imageView6" 
    android:layout_below="@+id/master_layout" 
    android:layout_toRightOf="@+id/imageView5" 
    android:layout_toEndOf="@+id/imageView5" /> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/imageView9" 
    android:background="@drawable/slice_2_2" 
    android:layout_gravity="fill" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_below="@+id/imageView6" 
    android:layout_alignLeft="@+id/imageView6" 
    android:layout_alignStart="@+id/imageView6" /> 

</RelativeLayout> 

對不起,打擾了。