[英]Android Camera2 - Remove black space between camera and bottom bar
我正在尝试开发一个使用Camera 2 API的应用程序,但是当我尝试编辑底栏的高度时我遇到了问题。 我想删除相机和底栏之间的黑色空间。 而且,我想延长相机的高度。
我关注了Google Camera2Basic示例。
我能解决这个问题吗?
谢谢。
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
<?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>
您可以添加动作栏,这将导致您的camera_view降低一点,并删除黑色分隔符。 在styles.xml中,替换此行
<style name="MaterialTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen" />
同
<style name="MaterialTheme" parent="android:Theme.Material.Light" />
如果您不想添加Actionbar,则可能必须修改AutoFitTextureView或Camera2BasicFragment类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.