【问题标题】:How to add button on camera Preview Frame in Android?如何在 Android 的相机预览框上添加按钮?
【发布时间】:2012-11-08 14:56:43
【问题描述】:

我只是将按钮拖放到相机预览帧上,但是当我在设备上执行应用程序时按钮不可见,我看不到按钮。请帮助解决此问题。我想在相机预览上添加一个 Flash 按钮。这是 XML 代码。

 

      

  

  
 线性布局>

【问题讨论】:

    标签: java android android-layout android-camera


    【解决方案1】:

    我认为您需要将LinearLayout 更改为RelativeLayout

    这是我正在使用的工作 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      相关资源
      最近更新 更多