-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback,android.view.KeyEvent.Callback,android.view.accessibility.AccessibilityEventSource
public class ViewfinderView extends View取景视图:主要用于渲染扫描相关的动画效果
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceViewfinderView.ViewfinderStyle取景框样式
public enumViewfinderView.LaserStyle扫描线样式
public enumViewfinderView.TextLocation文字位置
public enumViewfinderView.FrameGravity扫描框对齐方式
public interfaceViewfinderView.OnItemClickListenerItem点击监听
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ViewfinderView(Context context)ViewfinderView(Context context, AttributeSet attrs)ViewfinderView(Context context, AttributeSet attrs, int defStyleAttr)
-
Method Summary
Modifier and Type Method Description voidsetMaskColor(@ColorInt() int maskColor)设置 扫描区外遮罩的颜色 voidsetFrameColor(@ColorInt() int frameColor)设置 扫描区边框的颜色 voidsetLaserColor(@ColorInt() int laserColor)设置扫描区激光线的颜色 voidsetFrameCornerColor(@ColorInt() int frameCornerColor)设置扫描区边角的颜色 voidsetLabelTextPadding(float labelTextPadding)设置提示文本距离扫描区的间距 voidsetLabelTextWidth(int labelTextWidth)设置提示文本的宽度,默认为View的宽度 voidsetLabelTextLocation(ViewfinderView.TextLocation labelTextLocation)设置提示文本显示位置 voidsetLabelText(String labelText)设置提示文本信息 voidsetLabelTextColor(@ColorInt() int color)设置提示文本字体颜色 voidsetLabelTextSize(float textSize)设置提示文本字体大小 voidsetFrameWidth(int frameWidth)设置扫描框的宽度 voidsetFrameHeight(int frameHeight)设置扫描框的高度 voidsetLaserStyle(ViewfinderView.LaserStyle laserStyle)设置激光样式 voidsetLaserGridColumn(int laserGridColumn)设置网格激光扫描列数 voidsetLaserGridHeight(int laserGridHeight)设置网格激光扫描高度,为0时,表示动态铺满 voidsetFrameCornerStrokeWidth(int frameCornerStrokeWidth)设置扫描区边角的宽 voidsetFrameCornerSize(int frameCornerSize)设置扫描区边角的高 voidsetLaserMovementSpeed(int laserMovementSpeed)设置激光扫描的速度:即:每次移动的距离 voidsetLaserLineHeight(int laserLineHeight)设置扫描线高度 voidsetLaserAnimationInterval(int laserAnimationInterval)设置扫描动画延迟间隔时间,单位:毫秒 voidsetFrameLineStrokeWidth(int frameLineStrokeWidth)设置边框线宽度 voidsetFrameRatio(float frameRatio)设置扫描框的与视图宽的占比;默认:0. voidsetFramePaddingLeft(float framePaddingLeft)设置扫描框左边的间距 voidsetFramePaddingTop(float framePaddingTop)设置扫描框顶部的间距 voidsetFramePaddingRight(float framePaddingRight)设置扫描框右边的间距 voidsetFramePaddingBottom(float framePaddingBottom)设置扫描框底部的间距 voidsetFrameGravity(ViewfinderView.FrameGravity frameGravity)设置扫描框的对齐方式;默认居中对齐;即:CENTER voidsetFrameBitmap(Bitmap frameBitmap)设置扫描框图片 voidsetPointColor(@ColorInt() int pointColor)设置结果点的颜色 voidsetPointStrokeColor(@ColorInt() int pointStrokeColor)设置结果点描边的颜色 voidsetPointBitmap(Bitmap bitmap)设置结果点图片 voidsetPointAnimationInterval(int pointAnimationInterval)设置结果点的动画间隔时长;单位:毫秒 voidsetPointRadius(float pointRadius)设置结果点的半径 voidsetPointStrokeRadius(float pointStrokeRadius)设置结果点外圈描边的半径;默认为:pointRadius 的 pointStrokeRatio 倍 voidsetZoomSpeed(float zoomSpeed)设置显示结果点动画的缩放速度;默认为:0. voidsetPointRangeRadius(float pointRangeRadius)设置结果点有效点击范围半径;默认为:pointStrokeRadius 的 DEFAULT_RANGE_RATIO 倍;需要注意的是,因为有效点击范围是建立在结果点的基础之上才有意义的;其主要目的是为了支持一定的容错范围;所以如果在此方法之后;有直接或间接有调用setPointBitmap方法的话,那么 pointRangeRadius的值将会被覆盖。 voidsetLaserBitmap(Bitmap laserBitmap)设置激光扫描自定义图片 voidsetLaserBitmapRatio(float laserBitmapRatio)设置扫描线位图的宽度比例;默认为:0. voidsetLaserBitmapWidth(float laserBitmapWidth)设置扫描线位图的宽度 voidsetViewfinderStyle(int viewfinderStyle)设置取景框样式;支持:classic:经典样式(带扫描框那种)、popular:流行样式(不带扫描框) booleanisShowPoints()是否显示结果点 voidsetOnItemClickListener(ViewfinderView.OnItemClickListener listener)设置点击Item监听 voidonDraw(Canvas canvas)booleanonTouchEvent(MotionEvent event)voidshowScanner()显示扫描动画 voidshowResultPoints(List<Point> points)显示结果点 voidsetLabelTextColorResource(@ColorRes() int id)设置提示文本字体颜色 voidsetFrameDrawable(@DrawableRes() int drawableResId)设置扫描框图片 voidsetLaserDrawable(@DrawableRes() int drawableResId)设置激光扫描自定义图片 voidsetPointDrawable(@DrawableRes() int drawableResId)设置结果点图片 voidsetFramePadding(float left, float top, float right, float bottom)设置扫描框的间距 voidsetPointAnimation(boolean pointAnimation)设置是否显示结果点缩放动画;默认为:true -
Methods inherited from class android.view.View
addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addKeyboardNavigationClusters, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, addTouchables, animate, announceForAccessibility, autofill, bringToFront, buildDrawingCache, buildLayer, callOnClick, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, checkInputConnectionProxy, clearAnimation, clearFocus, clearViewTranslationCallback, combineMeasuredStates, computeScroll, computeSystemWindowInsets, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchCreateViewTranslationRequest, dispatchDisplayHint, dispatchDragEvent, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerCaptureChanged, dispatchPopulateAccessibilityEvent, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchScrollCaptureSearch, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, draw, drawableHotspotChanged, findFocus, findOnBackInvokedDispatcher, findViewById, findViewWithTag, findViewsWithText, focusSearch, forceHasOverlappingRendering, forceLayout, gatherTransparentRegion, generateDisplayHash, generateViewId, getAccessibilityClassName, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getImportantForContentCapture, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getOverlay, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getPreferKeepClearRects, getReceiveContentMimeTypes, getResources, getRevealOnFocusHint, getRight, getRootSurfaceControl, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollCaptureHint, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateDescription, getStateListAnimator, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTouchDelegate, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTranslationResponse, getViewTreeObserver, getVisibility, getWidth, getWindowId, getWindowInsetsController, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocus, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasPointerCapture, hasTransientState, hasWindowFocus, inflate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isAutoHandwritingEnabled, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isImportantForContentCapture, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingRelative, isPivotSet, isPreferKeepClear, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollContainer, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, jumpDrawablesToCurrentState, keyboardNavigationClusterSearch, layout, measure, offsetLeftAndRight, offsetTopAndBottom, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onCreateInputConnection, onCreateViewTranslationRequest, onCreateVirtualViewTranslationRequests, onDragEvent, onDrawForeground, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideContentCaptureStructure, onProvideStructure, onProvideVirtualStructure, onReceiveContent, onResolvePointerIcon, onRtlPropertiesChanged, onScreenStateChanged, onScrollCaptureSearch, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onViewTranslationResponse, onVirtualViewTranslationResponses, onVisibilityAggregated, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performLongClick, performReceiveContent, playSoundEffect, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreDefaultFocus, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAllowClickWhenDisabled, setAlpha, setAnimation, setAnimationMatrix, setAutoHandwritingEnabled, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForeground, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setImportantForContentCapture, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnReceiveContentListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPreferKeepClear, setPreferKeepClearRects, setPressed, setRenderEffect, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollBarSize, setScrollBarStyle, setScrollCaptureCallback, setScrollCaptureHint, setScrollContainer, setScrollIndicators, setScrollX, setScrollY, setScrollbarFadingEnabled, setSelected, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setViewTranslationCallback, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setWindowInsetsAnimationCallback, setX, setY, setZ, showContextMenu, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, updateDragShadow, willNotCacheDrawing, willNotDraw -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
setMaskColor
void setMaskColor(@ColorInt() int maskColor)
设置 扫描区外遮罩的颜色
- Parameters:
maskColor- 遮罩颜色
-
setFrameColor
void setFrameColor(@ColorInt() int frameColor)
设置 扫描区边框的颜色
- Parameters:
frameColor- 扫描区边框的颜色
-
setLaserColor
void setLaserColor(@ColorInt() int laserColor)
设置扫描区激光线的颜色
- Parameters:
laserColor- 激光线的颜色
-
setFrameCornerColor
void setFrameCornerColor(@ColorInt() int frameCornerColor)
设置扫描区边角的颜色
- Parameters:
frameCornerColor- 扫描区边角的颜色
-
setLabelTextPadding
void setLabelTextPadding(float labelTextPadding)
设置提示文本距离扫描区的间距
- Parameters:
labelTextPadding- 提示文本距离扫描区的间距
-
setLabelTextWidth
void setLabelTextWidth(int labelTextWidth)
设置提示文本的宽度,默认为View的宽度
- Parameters:
labelTextWidth- 提示文本的宽度
-
setLabelTextLocation
void setLabelTextLocation(ViewfinderView.TextLocation labelTextLocation)
设置提示文本显示位置
- Parameters:
labelTextLocation- 提示文本显示位置
-
setLabelText
void setLabelText(String labelText)
设置提示文本信息
- Parameters:
labelText- 提示文本信息
-
setLabelTextColor
void setLabelTextColor(@ColorInt() int color)
设置提示文本字体颜色
- Parameters:
color- 提示文本字体颜色
-
setLabelTextSize
void setLabelTextSize(float textSize)
设置提示文本字体大小
- Parameters:
textSize- 提示文本字体大小
-
setFrameWidth
void setFrameWidth(int frameWidth)
设置扫描框的宽度
- Parameters:
frameWidth- 扫描框的宽度
-
setFrameHeight
void setFrameHeight(int frameHeight)
设置扫描框的高度
- Parameters:
frameHeight- 扫描框的高度
-
setLaserStyle
void setLaserStyle(ViewfinderView.LaserStyle laserStyle)
设置激光样式
- Parameters:
laserStyle- 激光样式
-
setLaserGridColumn
void setLaserGridColumn(int laserGridColumn)
设置网格激光扫描列数
- Parameters:
laserGridColumn- 网格激光扫描列数
-
setLaserGridHeight
void setLaserGridHeight(int laserGridHeight)
设置网格激光扫描高度,为0时,表示动态铺满
- Parameters:
laserGridHeight- 网格激光扫描高度
-
setFrameCornerStrokeWidth
void setFrameCornerStrokeWidth(int frameCornerStrokeWidth)
设置扫描区边角的宽
- Parameters:
frameCornerStrokeWidth- 扫描区边角的宽
-
setFrameCornerSize
void setFrameCornerSize(int frameCornerSize)
设置扫描区边角的高
- Parameters:
frameCornerSize- 扫描区边角的高
-
setLaserMovementSpeed
void setLaserMovementSpeed(int laserMovementSpeed)
设置激光扫描的速度:即:每次移动的距离
- Parameters:
laserMovementSpeed- 激光扫描的速度
-
setLaserLineHeight
void setLaserLineHeight(int laserLineHeight)
设置扫描线高度
- Parameters:
laserLineHeight- 扫描线高度
-
setLaserAnimationInterval
void setLaserAnimationInterval(int laserAnimationInterval)
设置扫描动画延迟间隔时间,单位:毫秒
- Parameters:
laserAnimationInterval- 扫描动画延迟间隔时间
-
setFrameLineStrokeWidth
void setFrameLineStrokeWidth(int frameLineStrokeWidth)
设置边框线宽度
- Parameters:
frameLineStrokeWidth- 边框线宽度
-
setFrameRatio
void setFrameRatio(float frameRatio)
设置扫描框的与视图宽的占比;默认:0.625
- Parameters:
frameRatio- 扫描框的与视图宽的占比
-
setFramePaddingLeft
void setFramePaddingLeft(float framePaddingLeft)
设置扫描框左边的间距
- Parameters:
framePaddingLeft- 扫描框左边的间距
-
setFramePaddingTop
void setFramePaddingTop(float framePaddingTop)
设置扫描框顶部的间距
- Parameters:
framePaddingTop- 扫描框顶部的间距
-
setFramePaddingRight
void setFramePaddingRight(float framePaddingRight)
设置扫描框右边的间距
- Parameters:
framePaddingRight- 扫描框右边的间距
-
setFramePaddingBottom
void setFramePaddingBottom(float framePaddingBottom)
设置扫描框底部的间距
- Parameters:
framePaddingBottom- 扫描框底部的间距
-
setFrameGravity
void setFrameGravity(ViewfinderView.FrameGravity frameGravity)
设置扫描框的对齐方式;默认居中对齐;即:CENTER
- Parameters:
frameGravity- 扫描框的对齐方式
-
setFrameBitmap
void setFrameBitmap(Bitmap frameBitmap)
设置扫描框图片
- Parameters:
frameBitmap- 扫描框图片
-
setPointColor
void setPointColor(@ColorInt() int pointColor)
设置结果点的颜色
- Parameters:
pointColor- 结果点的颜色
-
setPointStrokeColor
void setPointStrokeColor(@ColorInt() int pointStrokeColor)
设置结果点描边的颜色
- Parameters:
pointStrokeColor- 结果点描边的颜色
-
setPointBitmap
void setPointBitmap(Bitmap bitmap)
设置结果点图片
- Parameters:
bitmap- 结果点图片
-
setPointAnimationInterval
void setPointAnimationInterval(int pointAnimationInterval)
设置结果点的动画间隔时长;单位:毫秒
- Parameters:
pointAnimationInterval- 结果点的动画间隔时长
-
setPointRadius
void setPointRadius(float pointRadius)
设置结果点的半径
- Parameters:
pointRadius- 结果点的半径
-
setPointStrokeRadius
void setPointStrokeRadius(float pointStrokeRadius)
设置结果点外圈描边的半径;默认为:pointRadius 的 pointStrokeRatio 倍
- Parameters:
pointStrokeRadius- 结果点外圈描边的半径
-
setZoomSpeed
void setZoomSpeed(float zoomSpeed)
设置显示结果点动画的缩放速度;默认为:0.02 / laserAnimationInterval
- Parameters:
zoomSpeed- 显示结果点动画的缩放速度
-
setPointRangeRadius
void setPointRangeRadius(float pointRangeRadius)
设置结果点有效点击范围半径;默认为:pointStrokeRadius 的 DEFAULT_RANGE_RATIO 倍;需要注意的是,因为有效点击范围是建立在结果点的基础之上才有意义的;其主要目的是为了支持一定的容错范围;所以如果在此方法之后;有直接或间接有调用setPointBitmap方法的话,那么 pointRangeRadius的值将会被覆盖。
- Parameters:
pointRangeRadius- 结果点有效点击范围半径
-
setLaserBitmap
void setLaserBitmap(Bitmap laserBitmap)
设置激光扫描自定义图片
- Parameters:
laserBitmap- 激光扫描自定义图片
-
setLaserBitmapRatio
void setLaserBitmapRatio(float laserBitmapRatio)
设置扫描线位图的宽度比例;默认为:0.625;此方法会改变laserBitmapWidth
- Parameters:
laserBitmapRatio- 扫描线位图的宽度比例
-
setLaserBitmapWidth
void setLaserBitmapWidth(float laserBitmapWidth)
设置扫描线位图的宽度
- Parameters:
laserBitmapWidth- 扫描线位图的宽度
-
setViewfinderStyle
void setViewfinderStyle(int viewfinderStyle)
设置取景框样式;支持:classic:经典样式(带扫描框那种)、popular:流行样式(不带扫描框)
- Parameters:
viewfinderStyle- 取景框样式
-
isShowPoints
boolean isShowPoints()
是否显示结果点
-
setOnItemClickListener
void setOnItemClickListener(ViewfinderView.OnItemClickListener listener)
设置点击Item监听
- Parameters:
listener- 点击Item监听器
-
onDraw
void onDraw(Canvas canvas)
-
onTouchEvent
boolean onTouchEvent(MotionEvent event)
-
showScanner
void showScanner()
显示扫描动画
-
showResultPoints
void showResultPoints(List<Point> points)
显示结果点
- Parameters:
points- 结果点
-
setLabelTextColorResource
void setLabelTextColorResource(@ColorRes() int id)
设置提示文本字体颜色
- Parameters:
id- 提示文本字体颜色资源ID
-
setFrameDrawable
void setFrameDrawable(@DrawableRes() int drawableResId)
设置扫描框图片
- Parameters:
drawableResId- 扫描框图片资源ID
-
setLaserDrawable
void setLaserDrawable(@DrawableRes() int drawableResId)
设置激光扫描自定义图片
- Parameters:
drawableResId- 激光扫描自定义图片资源ID
-
setPointDrawable
void setPointDrawable(@DrawableRes() int drawableResId)
设置结果点图片
- Parameters:
drawableResId- 结果点图片资源ID
-
setFramePadding
void setFramePadding(float left, float top, float right, float bottom)
设置扫描框的间距
- Parameters:
left- 扫描框左边的间距top- 扫描框顶部的间距right- 扫描框左边的间距bottom- 扫描框底部的间距
-
setPointAnimation
void setPointAnimation(boolean pointAnimation)
设置是否显示结果点缩放动画;默认为:true
- Parameters:
pointAnimation- 是否显示结果点缩放动画
-
-
-
-