2012-11-08 59 views
0

我只需將相機預覽框上的按鈕拖放,但在設備上執行應用程序時,該按鈕不可見,我看不到按鈕。請幫助解決此問題。我想在相機預覽中添加一個Flash按鈕。這裏是XML代碼。 如何在Android中添加相機預覽框中的按鈕?

 <FrameLayout 
     android:id="@+id/camera_preview" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1.05" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/flash_button" /> 

    </FrameLayout> 

    <Button 
    android:id="@+id/button_capture" 
    android:text="@string/capture_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    /> 
</LinearLayout> 

回答

0

I think you need to change the LinearLayoutRelativeLayout

下面是我使用的工作XML:

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

<FrameLayout 
    android:id="@+id/camera_preview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
</FrameLayout> 

<FrameLayout 
    android:id="@+id/indicator" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:background="@drawable/ind" > 
</FrameLayout> 

<Button 
    android:id="@+id/button_switchcam" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/btn_switch_button" 
    tools:ignore="HardcodedText" /> 

<Button 
    android:id="@+id/button_capture" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_centerVertical="true" 
    android:background="@drawable/btn_capture_button" 
    tools:ignore="HardcodedText" /> 

</RelativeLayout>