-
- 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
Fields Modifier and Type Field Description private intmaskColorprivate intframeColorprivate intlaserColorprivate intframeCornerColorprivate floatlabelTextPaddingprivate intlabelTextWidthprivate ViewfinderView.TextLocationlabelTextLocationprivate StringlabelTextprivate intlabelTextColorprivate floatlabelTextSizeprivate ViewfinderView.LaserStylelaserStyleprivate intlaserGridColumnprivate intlaserGridHeightprivate intframeCornerStrokeWidthprivate intframeCornerSizeprivate intlaserMovementSpeedprivate intlaserLineHeightprivate intlaserAnimationIntervalprivate intframeLineStrokeWidthprivate BitmapframeBitmapprivate intpointColorprivate intpointStrokeColorprivate BitmappointBitmapprivate intpointAnimationIntervalprivate floatpointRadiusprivate BitmaplaserBitmapprivate intviewfinderStyleprivate booleanisShowPointsprivate ViewfinderView.OnItemClickListeneronItemClickListener
-
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(int maskColor)设置 扫描区外遮罩的颜色 voidsetFrameColor(int frameColor)设置 扫描区边框的颜色 voidsetLaserColor(int laserColor)设置扫描区激光线的颜色 voidsetFrameCornerColor(int frameCornerColor)设置扫描区边角的颜色 voidsetLabelTextPadding(float labelTextPadding)设置提示文本距离扫描区的间距 voidsetLabelTextWidth(int labelTextWidth)设置提示文本的宽度,默认为View的宽度 voidsetLabelTextLocation(ViewfinderView.TextLocation labelTextLocation)设置提示文本显示位置 voidsetLabelText(String labelText)设置提示文本信息 voidsetLabelTextColor(@ColorInt() int color)设置提示文本字体颜色 voidsetLabelTextSize(float textSize)设置提示文本字体大小 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)设置边框线宽度 voidsetFrameBitmap(Bitmap frameBitmap)设置扫描框图片 voidsetPointColor(int pointColor)设置结果点的颜色 voidsetPointStrokeColor(int pointStrokeColor)设置结果点描边的颜色 voidsetPointBitmap(Bitmap bitmap)设置结果点图片 voidsetPointAnimationInterval(int pointAnimationInterval)设置点的动画间隔时长;单位:毫秒 voidsetPointRadius(float pointRadius)设置结果点的半径 voidsetLaserBitmap(Bitmap laserBitmap)设置激光扫描自定义图片 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)设置结果点图片 -
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(int maskColor)
设置 扫描区外遮罩的颜色
-
setFrameColor
void setFrameColor(int frameColor)
设置 扫描区边框的颜色
-
setLaserColor
void setLaserColor(int laserColor)
设置扫描区激光线的颜色
-
setFrameCornerColor
void setFrameCornerColor(int frameCornerColor)
设置扫描区边角的颜色
-
setLabelTextPadding
void setLabelTextPadding(float labelTextPadding)
设置提示文本距离扫描区的间距
-
setLabelTextWidth
void setLabelTextWidth(int labelTextWidth)
设置提示文本的宽度,默认为View的宽度
-
setLabelTextLocation
void setLabelTextLocation(ViewfinderView.TextLocation labelTextLocation)
设置提示文本显示位置
-
setLabelText
void setLabelText(String labelText)
设置提示文本信息
-
setLabelTextColor
void setLabelTextColor(@ColorInt() int color)
设置提示文本字体颜色
-
setLabelTextSize
void setLabelTextSize(float textSize)
设置提示文本字体大小
-
setLaserStyle
void setLaserStyle(ViewfinderView.LaserStyle laserStyle)
设置激光样式
-
setLaserGridColumn
void setLaserGridColumn(int laserGridColumn)
设置网格激光扫描列数
-
setLaserGridHeight
void setLaserGridHeight(int laserGridHeight)
设置网格激光扫描高度,为0时,表示动态铺满
-
setFrameCornerStrokeWidth
void setFrameCornerStrokeWidth(int frameCornerStrokeWidth)
设置扫描区边角的宽
-
setFrameCornerSize
void setFrameCornerSize(int frameCornerSize)
设置扫描区边角的高
-
setLaserMovementSpeed
void setLaserMovementSpeed(int laserMovementSpeed)
设置激光扫描的速度:即:每次移动的距离
-
setLaserLineHeight
void setLaserLineHeight(int laserLineHeight)
设置扫描线高度
-
setLaserAnimationInterval
void setLaserAnimationInterval(int laserAnimationInterval)
设置扫描动画延迟间隔时间,单位:毫秒
-
setFrameLineStrokeWidth
void setFrameLineStrokeWidth(int frameLineStrokeWidth)
设置边框线宽度
-
setFrameBitmap
void setFrameBitmap(Bitmap frameBitmap)
设置扫描框图片
-
setPointColor
void setPointColor(int pointColor)
设置结果点的颜色
-
setPointStrokeColor
void setPointStrokeColor(int pointStrokeColor)
设置结果点描边的颜色
-
setPointBitmap
void setPointBitmap(Bitmap bitmap)
设置结果点图片
-
setPointAnimationInterval
void setPointAnimationInterval(int pointAnimationInterval)
设置点的动画间隔时长;单位:毫秒
-
setPointRadius
void setPointRadius(float pointRadius)
设置结果点的半径
-
setLaserBitmap
void setLaserBitmap(Bitmap laserBitmap)
设置激光扫描自定义图片
-
setViewfinderStyle
void setViewfinderStyle(int viewfinderStyle)
设置取景框样式;支持:classic:经典样式(带扫描框那种)、popular:流行样式(不带扫描框)
-
isShowPoints
boolean isShowPoints()
是否显示结果点
-
setOnItemClickListener
void setOnItemClickListener(ViewfinderView.OnItemClickListener listener)
设置点击Item监听
-
onDraw
void onDraw(Canvas canvas)
-
onTouchEvent
boolean onTouchEvent(MotionEvent event)
-
showScanner
void showScanner()
显示扫描动画
-
showResultPoints
void showResultPoints(List<Point> points)
显示结果点
-
setLabelTextColorResource
void setLabelTextColorResource(@ColorRes() int id)
设置提示文本字体颜色
-
setFrameDrawable
void setFrameDrawable(@DrawableRes() int drawableResId)
设置扫描框图片
-
setLaserDrawable
void setLaserDrawable(@DrawableRes() int drawableResId)
设置激光扫描自定义图片
-
setPointDrawable
void setPointDrawable(@DrawableRes() int drawableResId)
设置结果点图片
-
-
-
-