简体   繁体   English

Android Camera2 - 移除相机和底栏之间的黑色空间

[英]Android Camera2 - Remove black space between camera and bottom bar

I'm trying to develop an application that uses Camera 2 API, but I have a problem when I try to edit the height of the bottom bar. 我正在尝试开发一个使用Camera 2 API的应用程序,但是当我尝试编辑底栏的高度时我遇到了问题。 I would like to remove the black space between the camera and bottom bar. 我想删除相机和底栏之间的黑色空间。 Moreover, I would like to extend the camera height. 而且,我想延长相机的高度。

I followed the Google Camera2Basic example. 我关注了Google Camera2Basic示例。

在此输入图像描述

Could I fix this problem? 我能解决这个问题吗?

Thanks. 谢谢。

activity_camera.xml activity_camera.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000"
    tools:context=".CameraActivity" />

fragment_camera2.xml fragment_camera2.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:foreground="?selectableItemBackground" >

    <widgets.AutoFitTextureView
        android:id="@+id/texture"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true" />

    <FrameLayout
        android:id="@+id/control"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:elevation="4dp"
        android:paddingBottom="12dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingTop="12dp"
        android:background="@color/white" >

        <ImageButton
            android:id="@+id/picture"
            android:layout_width="@dimen/ic_camera"
            android:layout_height="@dimen/ic_camera"
            android:layout_gravity="center"
            android:background="@drawable/cam_circle_selector"
            android:contentDescription="@string/description_info"
            android:scaleType="fitXY"
            app:srcCompat="@drawable/ic_action_capture" />

    </FrameLayout>

</RelativeLayout>

You can add the Actionbar back which will cause your camera_view getting a little lower and remove the black divider. 您可以添加动作栏,这将导致您的camera_view降低一点,并删除黑色分隔符。 In styles.xml, replace this line 在styles.xml中,替换此行

<style name="MaterialTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen" />

with

<style name="MaterialTheme" parent="android:Theme.Material.Light" />

If you don't want to add Actionbar, you may have to modify AutoFitTextureView or Camera2BasicFragment class. 如果您不想添加Actionbar,则可能必须修改AutoFitTextureView或Camera2BasicFragment类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM