public class CameraView
extends android.widget.FrameLayout
implements android.arch.lifecycle.LifecycleObserver
android.widget.FrameLayout.LayoutParamsandroid.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListenerandroid.view.View.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnApplyWindowInsetsListener, android.view.View.OnAttachStateChangeListener, android.view.View.OnCapturedPointerListener, android.view.View.OnClickListener, android.view.View.OnContextClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnScrollChangeListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener, android.view.View.OnUnhandledKeyEventListener| Modifier and Type | Field and Description |
|---|---|
static int |
PERMISSION_REQUEST_CODE |
CLIP_TO_PADDING_MASK, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, LAYOUT_MODE_CLIP_BOUNDS, LAYOUT_MODE_OPTICAL_BOUNDS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHEACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, AUTOFILL_HINT_CREDIT_CARD_NUMBER, AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, AUTOFILL_HINT_EMAIL_ADDRESS, AUTOFILL_HINT_NAME, AUTOFILL_HINT_PASSWORD, AUTOFILL_HINT_PHONE, AUTOFILL_HINT_POSTAL_ADDRESS, AUTOFILL_HINT_POSTAL_CODE, AUTOFILL_HINT_USERNAME, AUTOFILL_TYPE_DATE, AUTOFILL_TYPE_LIST, AUTOFILL_TYPE_NONE, AUTOFILL_TYPE_TEXT, AUTOFILL_TYPE_TOGGLE, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, IMPORTANT_FOR_AUTOFILL_AUTO, IMPORTANT_FOR_AUTOFILL_NO, IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_AUTOFILL_YES, IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z| Constructor and Description |
|---|
CameraView(android.content.Context context) |
CameraView(android.content.Context context,
android.util.AttributeSet attrs) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCameraListener(CameraListener cameraListener)
Adds a
CameraListener instance to be notified of all
interesting events that happen during the camera lifecycle. |
void |
addFrameProcessor(FrameProcessor processor)
Adds a
FrameProcessor instance to be notified of
new frames in the preview stream. |
void |
capturePicture()
Asks the camera to capture an image of the current scene.
|
void |
captureSnapshot()
Asks the camera to capture a snapshot of the current preview.
|
protected boolean |
checkPermissions(SessionType sessionType,
Audio audio)
Checks that we have appropriate permissions for this session type.
|
void |
clearCameraListeners()
Clears the list of
CameraListener that are registered
to camera events. |
void |
clearFrameProcessors()
Clears the list of
FrameProcessor that have been registered
to preview frames. |
void |
clearGesture(Gesture gesture)
Clears any action mapped to the given gesture.
|
void |
destroy()
Destroys this instance, releasing immediately
the camera resource.
|
Audio |
getAudio()
Gets the current audio value.
|
CameraOptions |
getCameraOptions()
Returns a
CameraOptions instance holding supported options for this camera
session. |
Size |
getCaptureSize()
Deprecated.
use
getPictureSize() instead. |
boolean |
getCropOutput()
Returns whether we should crop the picture output to match CameraView aspect ratio.
|
float |
getExposureCorrection()
Returns the current exposure correction value, typically 0
at start-up.
|
ExtraProperties |
getExtraProperties()
If present, returns a collection of extra properties from the current camera
session.
|
Facing |
getFacing()
Gets the facing camera currently being used.
|
Flash |
getFlash()
Gets the current flash mode.
|
GestureAction |
getGestureAction(Gesture gesture)
Returns the action currently mapped to the given gesture.
|
Grid |
getGrid()
Gets the current grid mode.
|
Hdr |
getHdr()
Gets the current hdr value.
|
int |
getJpegQuality()
Gets the JPEG compression quality for image outputs.
|
android.location.Location |
getLocation()
Retrieves the location previously applied with setLocation().
|
Size |
getPictureSize()
Returns the size used for the capture,
or null if it hasn't been computed yet (for example if the surface is not ready).
|
boolean |
getPlaySounds()
Gets the current sound effect behavior.
|
Size |
getPreviewSize()
Returns the size used for the preview,
or null if it hasn't been computed (for example if the surface is not ready).
|
SessionType |
getSessionType()
Gets the current session type.
|
Size |
getSnapshotSize()
Returns the size used for capturing snapshots.
|
VideoCodec |
getVideoCodec()
Gets the current encoder for video recordings.
|
int |
getVideoMaxDuration()
Returns the maximum duration in milliseconds for video recordings, or 0
if no limit was set.
|
long |
getVideoMaxSize()
Returns the maximum size in bytes for recorded video files, or 0
if no size was set.
|
VideoQuality |
getVideoQuality()
Gets the current video quality.
|
WhiteBalance |
getWhiteBalance()
Returns the current white balance behavior.
|
float |
getZoom()
Returns the current zoom value, something between 0 and 1.
|
protected com.otaliastudios.cameraview.CameraController |
instantiateCameraController(com.otaliastudios.cameraview.CameraView.CameraCallbacks callbacks) |
protected com.otaliastudios.cameraview.CameraPreview |
instantiatePreview(android.content.Context context,
android.view.ViewGroup container) |
boolean |
isCapturingVideo()
Returns true if the camera is currently recording a video
|
boolean |
isStarted()
Returns whether the camera has started showing its preview.
|
boolean |
mapGesture(Gesture gesture,
GestureAction action)
Maps a
Gesture to a certain gesture action. |
protected void |
onAttachedToWindow() |
protected void |
onDetachedFromWindow() |
boolean |
onInterceptTouchEvent(android.view.MotionEvent ev) |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
Measuring is basically controlled by layout params width and height.
|
boolean |
onTouchEvent(android.view.MotionEvent event) |
void |
removeCameraListener(CameraListener cameraListener)
Remove a
CameraListener that was previously registered. |
void |
removeFrameProcessor(FrameProcessor processor)
Remove a
FrameProcessor that was previously registered. |
void |
set(Control control)
Shorthand for the appropriate set* method.
|
void |
setAudio(Audio audio)
Controls the audio mode.
|
void |
setCameraListener(CameraListener cameraListener)
Deprecated.
use
addCameraListener(CameraListener) instead. |
void |
setCropOutput(boolean cropOutput)
Whether we should crop the picture output to match CameraView aspect ratio.
|
void |
setExposureCorrection(float EVvalue)
Sets exposure adjustment, in EV stops.
|
void |
setFacing(Facing facing)
Sets which camera sensor should be used.
|
void |
setFlash(Flash flash)
Sets the flash mode.
|
void |
setGrid(Grid gridMode)
Controls the grids to be drawn over the current layout.
|
void |
setHdr(Hdr hdr)
Controls the grids to be drawn over the current layout.
|
void |
setJpegQuality(int jpegQuality)
Sets the JPEG compression quality for image outputs.
|
void |
setLifecycleOwner(android.arch.lifecycle.LifecycleOwner owner)
Sets the lifecycle owner for this view.
|
void |
setLocation(double latitude,
double longitude)
Set location coordinates to be found later in the jpeg EXIF header
|
void |
setLocation(android.location.Location location)
Set location values to be found later in the jpeg EXIF header
|
void |
setPictureSize(SizeSelector selector)
Sets picture capture size.
|
void |
setPlaySounds(boolean playSounds)
Controls whether CameraView should play sound effects on certain
events (picture taken, focus complete).
|
void |
setSessionType(SessionType sessionType)
Set the current session type to either picture or video.
|
void |
setVideoCodec(VideoCodec codec)
Sets the encoder for video recordings.
|
void |
setVideoMaxDuration(int videoMaxDurationMillis)
Sets the maximum duration in milliseconds for video recordings.
|
void |
setVideoMaxSize(long videoMaxSizeInBytes)
Sets the maximum size in bytes for recorded video files.
|
void |
setVideoQuality(VideoQuality videoQuality)
Sets video recording quality.
|
void |
setWhiteBalance(WhiteBalance whiteBalance)
Sets desired white balance to current camera session.
|
void |
setZoom(float zoom)
Sets a zoom value.
|
void |
start()
Starts the camera preview, if not started already.
|
void |
startAutoFocus(float x,
float y)
Starts an autofocus process at the given coordinates, with respect
to the view width and height.
|
void |
startCapturingVideo()
Deprecated.
|
void |
startCapturingVideo(java.io.File file)
Starts recording a video.
|
void |
startCapturingVideo(java.io.File file,
long durationMillis)
Deprecated.
use
setVideoMaxDuration(int) instead. |
void |
stop()
Stops the current preview, if any was started.
|
void |
stopCapturingVideo()
Stops capturing video, if there was a video record going on.
|
Facing |
toggleFacing()
Toggles the facing value between
Facing.BACK
and Facing.FRONT. |
Flash |
toggleFlash()
Deprecated.
Don't use this. Flash values might not be supported,
and the return value is unreliable.
|
checkLayoutParams, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, getAccessibilityClassName, getConsiderGoneChildrenWhenMeasuring, getMeasureAllChildren, onLayout, setForegroundGravity, setMeasureAllChildren, shouldDelayChildPressedStateaddChildrenForAccessibility, addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, findViewsWithText, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onCreateDrawableState, onDescendantInvalidated, onInterceptHoverEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, restoreDefaultFocus, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, showContextMenuForChild, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, updateViewLayoutaddExtraDataToAccessibilityNodeInfo, addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, autofill, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getApplicationWindowToken, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getImportantForAccessibility, getImportantForAutofill, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDraw, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onOverScrolled, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideStructure, onProvideVirtualStructure, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTrackballEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForeground, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionName, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, unscheduleDrawable, unscheduleDrawable, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDrawclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcanResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch, requestFitSystemWindows, requestLayoutpublic static final int PERMISSION_REQUEST_CODE
public CameraView(@NonNull
android.content.Context context)
public CameraView(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs)
protected com.otaliastudios.cameraview.CameraController instantiateCameraController(com.otaliastudios.cameraview.CameraView.CameraCallbacks callbacks)
protected com.otaliastudios.cameraview.CameraPreview instantiatePreview(android.content.Context context,
android.view.ViewGroup container)
protected void onAttachedToWindow()
onAttachedToWindow in class android.view.ViewGroupprotected void onDetachedFromWindow()
onDetachedFromWindow in class android.view.ViewGroupprotected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
CameraPreview, this acts like
a CENTER CROP scale type.
When both dimensions are WRAP_CONTENT, CameraView will take the biggest dimensions that
fit the preview aspect ratio. This acts like a CENTER INSIDE scale type.onMeasure in class android.widget.FrameLayoutpublic boolean mapGesture(@NonNull
Gesture gesture,
GestureAction action)
Gesture to a certain gesture action.
For example, you can assign zoom control to the pinch gesture by just calling:
cameraView.mapGesture(Gesture.PINCH, GestureAction.ZOOM);
Not all actions can be assigned to a certain gesture. For example, zoom control can't be
assigned to the Gesture.TAP gesture. Look at Gesture to know more.
This method returns false if they are not assignable.gesture - which gesture to mapaction - which action should be assignedpublic void clearGesture(@NonNull
Gesture gesture)
gesture - which gesture to clearpublic GestureAction getGestureAction(@NonNull Gesture gesture)
gesture - which gesture to inspectpublic boolean onInterceptTouchEvent(android.view.MotionEvent ev)
onInterceptTouchEvent in class android.view.ViewGrouppublic boolean onTouchEvent(android.view.MotionEvent event)
onTouchEvent in class android.view.Viewpublic boolean isStarted()
public void setLifecycleOwner(android.arch.lifecycle.LifecycleOwner owner)
start(), stop() or destroy() at all.owner - the owner activity or fragmentpublic void start()
protected boolean checkPermissions(SessionType sessionType, Audio audio)
sessionType - the sessionType to be checkedaudio - the audio setting to be checkedpublic void stop()
public void destroy()
public void set(Control control)
Grid, this calls setGrid(Grid).control - desired value@Nullable public CameraOptions getCameraOptions()
CameraOptions instance holding supported options for this camera
session. This might change over time. It's better to hold a reference from
CameraListener.onCameraOpened(CameraOptions).@Nullable public ExtraProperties getExtraProperties()
public void setExposureCorrection(float EVvalue)
CameraOptions.isExposureCorrectionSupported() is false, this will have no effect.
The provided value should be between the bounds returned by CameraOptions, or it will
be capped.EVvalue - exposure correction value.CameraOptions.getExposureCorrectionMinValue(),
CameraOptions.getExposureCorrectionMaxValue()public float getExposureCorrection()
public void setZoom(float zoom)
CameraOptions.isZoomSupported().
This will have no effect if called before the camera is opened.
Zoom value should be between 0 and 1, where 1 will be the maximum available zoom.
If it's not, it will be capped.zoom - value in [0,1]public float getZoom()
public void setGrid(Grid gridMode)
gridMode - desired grid modeGrid.OFF,
Grid.DRAW_3X3,
Grid.DRAW_4X4,
Grid.DRAW_PHIpublic Grid getGrid()
public void setHdr(Hdr hdr)
public Hdr getHdr()
public void setLocation(double latitude,
double longitude)
latitude - current latitudelongitude - current longitudepublic void setLocation(android.location.Location location)
location - current location@Nullable public android.location.Location getLocation()
public void setWhiteBalance(WhiteBalance whiteBalance)
whiteBalance - desired white balance behavior.WhiteBalance.AUTO,
WhiteBalance.INCANDESCENT,
WhiteBalance.FLUORESCENT,
WhiteBalance.DAYLIGHT,
WhiteBalance.CLOUDYpublic WhiteBalance getWhiteBalance()
public void setFacing(Facing facing)
facing - a facing value.Facing.FRONT,
Facing.BACKpublic Facing getFacing()
public Facing toggleFacing()
Facing.BACK
and Facing.FRONT.public void setFlash(Flash flash)
flash - desired flash mode.Flash.OFF,
Flash.ON,
Flash.AUTO,
Flash.TORCHpublic Flash getFlash()
public void setAudio(Audio audio)
public Audio getAudio()
public void startAutoFocus(float x,
float y)
x - should be between 0 and getWidth()y - should be between 0 and getHeight()public void setSessionType(SessionType sessionType)
startCapturingVideo(File) will not throw any exception
- capturePicture() might fallback to captureSnapshot() or might not worksessionType - desired session type.SessionType.PICTURE,
SessionType.VIDEOpublic SessionType getSessionType()
public void setPictureSize(@NonNull
SizeSelector selector)
SizeSelector will be invoked with the list of available
size, and the first acceptable size will be accepted and passed to the internal engine.
See the SizeSelectors class for handy utilities for creating selectors.selector - a size selectorpublic void setVideoQuality(VideoQuality videoQuality)
videoQuality - requested video qualityVideoQuality.LOWEST,
VideoQuality.HIGHEST,
VideoQuality.MAX_QVGA,
VideoQuality.MAX_480P,
VideoQuality.MAX_720P,
VideoQuality.MAX_1080P,
VideoQuality.MAX_2160Ppublic VideoQuality getVideoQuality()
public void setJpegQuality(int jpegQuality)
jpegQuality - a 0-100 integer.public int getJpegQuality()
public void setCropOutput(boolean cropOutput)
cropOutput - whether to croppublic boolean getCropOutput()
setCropOutput(boolean)@Deprecated public void setCameraListener(CameraListener cameraListener)
addCameraListener(CameraListener) instead.CameraListener instance to be notified of all
interesting events that will happen during the camera lifecycle.cameraListener - a listener for events.public void addCameraListener(CameraListener cameraListener)
CameraListener instance to be notified of all
interesting events that happen during the camera lifecycle.cameraListener - a listener for events.public void removeCameraListener(CameraListener cameraListener)
CameraListener that was previously registered.cameraListener - a listener for events.public void clearCameraListeners()
CameraListener that are registered
to camera events.public void addFrameProcessor(FrameProcessor processor)
FrameProcessor instance to be notified of
new frames in the preview stream.processor - a frame processor.public void removeFrameProcessor(FrameProcessor processor)
FrameProcessor that was previously registered.processor - a frame processorpublic void clearFrameProcessors()
FrameProcessor that have been registered
to preview frames.public void capturePicture()
CameraListener.onPictureTaken(byte[]) if a listener
was registered.
Note that if sessionType is SessionType.VIDEO, this
might fall back to captureSnapshot() (that is, we might capture a preview frame).captureSnapshot()public void captureSnapshot()
CameraListener.onPictureTaken(byte[]) if a listener
was registered.
The difference with capturePicture() is that this capture is faster, so it might be
better on slower cameras, though the result can be generally blurry or low quality.capturePicture()@Deprecated public void startCapturingVideo()
startCapturingVideo(File)startCapturingVideo(File) instead.public void startCapturingVideo(java.io.File file)
file - a file where the video will be saved@Deprecated
public void startCapturingVideo(java.io.File file,
long durationMillis)
setVideoMaxDuration(int) instead.setVideoMaxDuration(int).file - a file where the video will be saveddurationMillis - recording max durationpublic void stopCapturingVideo()
CameraListener.onVideoTaken(File).@Nullable public Size getPreviewSize()
@Nullable public Size getPictureSize()
@Nullable public Size getSnapshotSize()
getPreviewSize().public void setPlaySounds(boolean playSounds)
playSounds - whether to play sound effectspublic boolean getPlaySounds()
setPlaySounds(boolean)public void setVideoCodec(VideoCodec codec)
VideoCodec.DEVICE_DEFAULT.codec - requested video codecVideoCodec.DEVICE_DEFAULT,
VideoCodec.H_263,
VideoCodec.H_264public VideoCodec getVideoCodec()
public void setVideoMaxSize(long videoMaxSizeInBytes)
videoMaxSizeInBytes - The maximum video size in bytespublic long getVideoMaxSize()
setVideoMaxSize(long)public void setVideoMaxDuration(int videoMaxDurationMillis)
videoMaxDurationMillis - The maximum video duration in millisecondspublic int getVideoMaxDuration()
setVideoMaxDuration(int)public boolean isCapturingVideo()
@Deprecated @Nullable public Size getCaptureSize()
getPictureSize() instead.@Deprecated public Flash toggleFlash()