如何在Android相机对象上使用主题?

时间:2015-09-10 04:28:50

标签: android camera apk

我有一个简单的Android应用程序,有两个屏幕。第一个屏幕是默认摄像头。第二个屏幕用于捕获图像查看,并有几个按钮用于对图像采取操作。

我想在第一个屏幕的相机对象上使用自定义设计(主题/皮肤)。我怎么能这样做?

我附上了两个屏幕的模型。第一张图片是相机预览,第二张是图片审查。使用相机预览需要达到的最终结果应该是这样的:

Camera Preview with theme

1 个答案:

答案 0 :(得分:0)

如果你想添加像按钮这样的额外元素,你可以将它们添加到

<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"
        android:layout_margin="5dp">

        //Your camera preview
        <FrameLayout
            android:id="@+id/camera_preview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:layout_alignParentTop="true"
            android:layout_above="@+id/red_button" />

        //A Button on the camera preview near the bottom of the screen
        <Button
            android:id="@+id/take_picture"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@id/camera_preview"
            android:layout_margin="10dp"
            android:text="take picture" />

        <Button
            android:id="@id/red_button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_margin="5dp" />

</RelativeLayout>

当Frame布局添加相机预览的表面视图时。

但我不会尝试在表面视图中构建性能问题,而是尝试创建自己的自定义视图并覆盖onDraw方法以直接在视图上绘制。