android快手视频截取控件,自定义View 视频截取控件

抖音最近很火,可以说是app界的方向标。各种模仿也是层出不穷,最近项目有一个需求,需要做视频截取,两边拖动,选取中间的视频部分。

效果如下:

c66378b70c3a

image.png

实现思路:通过自定义view 根据手指onTouch 坐标动态刷新ondraw 绘制刷新的视图,回调对应的区域阀值。

自定义拖动视图SeekView

public class VideoSliceSeekBar extends View {

enum SelectThumb {

//没有选中滑块

SELECT_THUMB_NONE,

//选中左边滑块

SELECT_THUMB_LEFT,

//选中右边滑块

SELECT_THUMB_RIGHT,

}

public VideoSliceSeekBar(Context context) {

this(context, null);

}

public VideoSliceSeekBar(Context context, AttributeSet attrs) {

this(context, attrs, 0);

}

public VideoSliceSeekBar(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

initValue();

}

上面定义了对应滑动的枚举,左边滑动view 右边以及另外的区域

private void initValue() {

paintThumb.setAntiAlias(true);

paintThumb.setFilterBitmap(true);

int resSweepLeft = R.drawable.ic_produce_cut_left;

thumbSliceLeft = BitmapFactory.decodeResource(getResources(), resSweepLeft);

int resSweepRight = R.drawable.ic_produce_cut_right;

thumbSliceRight = BitmapFactory.decodeResource(getResources(), resSweepRight);

int resFrame = R.drawable.ic_produce_cut_frame;

thumbFrame = BitmapFactory.decodeResource(getResources(), resFrame);

topBottomPadding = DensityUtil.dp2px(getContext(), 6);

progress = ObjectAnimator.ofFloat(this, "progress", 0).setDuration(400);

progress.setInterpolator(new LinearInterpolator());

<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值