2012-08-01 42 views
1

因此,我有一個使用的xml佈局,它有兩個主要元素,一個包含相機預覽的framelayout和一個imageview。圖像視圖應該在framelayout上可見,並且直到camerapreview被打開,然後才被推到後面。我究竟做錯了什麼?在相機預覽版上放置ImageView

我做了很多測試,從佈局和重建中刪除元素,我似乎無法修復錯誤的原因,我相信原因必須在代碼中的某個地方。

回答

2

我認爲應該推動它,因爲是RelativeLayout。我認爲你應該使用LinearLayout。在RelativeLayout中屬性android:layout_weight="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="390dip" 
    android:layout_marginTop="25dip">   

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="300dip" 
     android:layout_height="305dip" 
     android:background="#00000000" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/try_3" 
     android:visibility="visible" 
     android:layout_marginLeft="10dip"/> 

    <FrameLayout 
     android:id="@+id/previewframe1" 
     android:layout_width="320dip" 
     android:layout_height="310dip" 
     android:layout_alignParentTop="true" 
     > 
    </FrameLayout> 

</RelativeLayout> 

希望有所幫助。

+0

如何將它們放在彼此的頂部,如果它的LinearLayout?此外,它的作品,當我不打開相機預覽,但一旦我把它打破。我確實刪除了重量 – Peter 2012-08-01 23:48:49

+0

看看我的編輯,看看是否你想要的。 – 0gravity 2012-08-01 23:53:57

+0

還是沒有im抱歉,我認爲這個問題是與相機預覽類或代碼 – Peter 2012-08-01 23:57:25

0

請爲透明度設置ImageView的背景和/或其包含的佈局android:background =「@ null」。

+0

我剛剛嘗試過,但沒有任何改變 – Peter 2012-08-01 23:53:05