Skip to content

Commit

Permalink
修改相机按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
Knightwood committed May 7, 2023
1 parent 29a4a1d commit a0932bb
Show file tree
Hide file tree
Showing 13 changed files with 477 additions and 797 deletions.
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,60 @@ cameraHolder = CameraHolder(
.setMinFaceSize(0.6f)//人脸最小占图片的百分比
```


# cameraButtom

此按钮控件用于拍照和录像,支持点击拍照,点击录像和长按录像,长按录制有动画

支持设置录制时长,到达录制时长后回调通知结束录制。

可以设置按钮仅支持拍照,仅支持录制,或都支持

1. 在开启长按录制时,点击录制将不可用

2. 开启点击录制时,拍照不可用

布局文件示例

```
<com.kiylx.camerax_lib.main.buttons.CameraButton
android:id="@+id/full_capture_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:buttonMode="both" //指定可拍照,可录制
app:longPassRecord="true" //开启长按录制
app:layout_constraintTop_toTopOf="parent"
app:size="80" />
```

使用示例

```
page.fullCaptureBtn.setCaptureListener(object : DefaultCaptureListener(){
//拍照
override fun takePictures() {
cameraXFragment.takePhoto()
}
//开始录制视频
override fun recordStart() {
page.captureVideoBtn.visibility = View.GONE
LogUtils.dTag("录制activity", "开始")
cameraXFragment.takeVideo()
//录制视频时隐藏摄像头切换
page.switchBtn.visibility=View.GONE
}
//录制视频到达预定的时长,可以结束了
override fun recordShouldEnd(time: Long) {
page.captureVideoBtn.visibility = View.VISIBLE
LogUtils.dTag("录制activity", "停止")
cameraXFragment.stopTakeVideo(time)
page.switchBtn.visibility=View.VISIBLE
}
})
```

# 示例代码在app目录下。

2 changes: 0 additions & 2 deletions camerax_lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application>

<activity android:name=".main.CameraXActivity" />
</application>

</manifest>
Loading

0 comments on commit a0932bb

Please sign in to comment.