OpenCV开发之——页面效果处理(1)

}

public CircleViewGroup(Context context, AttributeSet attrs) {

super(context, attrs);

}

public CircleViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

}

@Override

protected void dispatchDraw(Canvas canvas) {

Path path = new Path();

int verticalCenter = getHeight() / 2;

int horizontalCenter = getWidth() / 2;

radio=getWidth() / 3.5f;

path.addCircle(horizontalCenter, verticalCenter, radio, Path.Direction.CW);

canvas.clipPath(path);

super.dispatchDraw(canvas);

}

@Override

public boolean shouldDelayChildPressedState() {

return false;

}

}

4.2.2 RoundRectViewGroup

import android.content.Context;

import android.graphics.Canvas;

import android.graphics.Path;

import android.graphics.RectF;

import android.util.AttributeSet;

import android.widget.FrameLayout;

public class RoundRectViewGroup extends FrameLayout {

private float radio = 0;

public RoundRectViewGroup(Context context) {

super(context);

}

public RoundRectViewGroup(Context context, AttributeSet attrs) {

super(context, attrs);

}

public RoundRectViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

}

@Override

protected void dispatchDraw(Canvas canvas) {

Path path = new Path();

radio=getWidth() / 3.5f;

path.addRoundRect(

new RectF(0, 0, getWidth(), getHeight())

, new float[]{radio, radio, radio, radio, radio, radio, radio, radio}

, Path.Direction.CW);

canvas.clipPath(path);

super.dispatchDraw(canvas);

}

@Override

public boolean shouldDelayChildPressedState() {

return false;

}

}

4.3 布局文件

<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”>

<org.opencv.samples.view.CircleViewGroup

android:layout_width=“630dp”

android:layout_centerInParent=“true”

android:layout_height=“630dp”>

<org.opencv.android.JavaCameraView

android:id=“@+id/fd_activity_surface_view”

android:layout_width=“fill_parent”

android:layout_height=“fill_parent” />

</org.opencv.samples.view.CircleViewGroup>

4.4 效果图

| 圆形效果 | 矩形效果 |

| :-: | :-: |

| [外链图片转存中…(img-enTEs8sj-1714786475360)] | [外链图片转存中…(img-fbD6miuU-1714786475364)] |

五 人脸识别时的动画效果


5.1 说明

  • 圆形区域的外层增加一层旋转动画

  • 使用Lottie动画,作为旋转动画

  • Lottie跟JavaCameraView同处于相对布局中

5.2 布局图

<RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:app=“http://schemas.android.com/apk/res-auto”

xmlns:tools=“http://schemas.android.com/tools”

android:layout_width=“match_parent”

android:layout_height=“match_parent”>

<RelativeLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_centerInParent=“true”

android:gravity=“center”>

<org.opencv.samples.view.CircleViewGroup

android:layout_width=“630dp”

android:layout_height=“630dp”

android:layout_centerInParent=“true”>

<org.opencv.android.JavaCameraView

android:id=“@+id/fd_activity_surface_view”

android:layout_width=“600dp”

android:layout_height=“600dp”

android:layout_centerInParent=“true” />

</org.opencv.samples.view.CircleViewGroup>

<com.airbnb.lottie.LottieAnimationView

android:id=“@+id/animation_view”

android:layout_width=“400dp”

android:layout_height=“400dp”

android:layout_centerInParent=“true”

app:lottie_autoPlay=“true”

app:lottie_fileName=“anim/ring-rotate.json”

app:lottie_loop=“true” />

文末

当你打算跳槽的时候,应该把“跳槽成功后,我能学到什么东西?对我的未来发展有什么好处”放在第一位。这些东西才是真正引导你的关键。在跳槽之前尽量“物尽其用”,把手头上的工作做好,最好是完成了某个项目或是得到提升之后再走。跳槽不是目的,而是为了达到最终职业目标的手段

最后祝大家工作升职加薪,面试拿到心仪Offer



《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!
展有什么好处”放在第一位。这些东西才是真正引导你的关键。在跳槽之前尽量“物尽其用”,把手头上的工作做好,最好是完成了某个项目或是得到提升之后再走。跳槽不是目的,而是为了达到最终职业目标的手段**

最后祝大家工作升职加薪,面试拿到心仪Offer

[外链图片转存中…(img-jEHDGzuu-1714786475366)]
[外链图片转存中…(img-xo4SuAfu-1714786475368)]
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》点击传送门,即可获取!

  • 24
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值