【发布时间】:2012-11-08 14:56:43
【问题描述】:
我只是将按钮拖放到相机预览帧上,但是当我在设备上执行应用程序时按钮不可见,我看不到按钮。请帮助解决此问题。我想在相机预览上添加一个 Flash 按钮。这是 XML 代码。
线性布局>
【问题讨论】:
标签: java android android-layout android-camera
我只是将按钮拖放到相机预览帧上,但是当我在设备上执行应用程序时按钮不可见,我看不到按钮。请帮助解决此问题。我想在相机预览上添加一个 Flash 按钮。这是 XML 代码。
线性布局>
【问题讨论】:
标签: java android android-layout android-camera
我认为您需要将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>
【讨论】: