public class ScrollableLayout
extends android.widget.FrameLayout
This is the main ViewGroup for implementing Scrollable.
It has the same as FrameLayout.onMeasure(int, int) measure logic,
but has it's own onLayout(boolean, int, int, int, int) logic.
Note, that this ViewGroup will layout it's children as if it were an ordinary LinearLayout
with orientation set to LinearLayout.VERTICAL.
No paddings or margins will affect the layout position of children,
although margins will certainly affect measurements.
The best usage would be to include two View views.
The first one would represent the header logic and the second would be scrollable container.
Note, that we should make use of ViewGroup.LayoutParams.MATCH_PARENT
as the height attribute for scrollable container. Because it directly affects the scrollable behavior.
If you wish to create a sticky effect for one of the views in header ViewGroup,
you could specify layout_marginTop attribute for your scrollable layout,
which represents the height of your sticky element.
The logic behind scenes is simple. We should be able to encapsulate scrollable logic in a way (in a tabs case),
that saves us from adding header placeholders and footers (so that scrollY does
not change when different tab is selected) to every ScrollView, AbsListView etc.
So, instead of modifying scrolling behavior of each scrollable View, we are creating our own
ViewGroup that handles it for us.
Follow these steps to create your own Scrollable layout:
Simple case
<ru.noties.scrollable.ScrollableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:scrollable_maxScroll="@dimen/header_height"> <!-- (!) -->
<View
android:layout_width="match_parent"
android:layout_height="@dimen/header_height" /> <!-- (!) -- >
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ru.noties.scrollable.ScrollableLayout>
Sticky case
(of cause it's just an xml step, you also should implement translation logic in OnScrollChangeListener
setOnScrollChangedListener(OnScrollChangedListener))
<ru.noties.scrollable.ScrollableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:scrollable_maxScroll="@dimen/header_height">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="@dimen/header_height" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/sticky_height" /> <!-- (!) -->
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/sticky_height" /> <!-- (!) -->
Created by Dimitry Ivanov (mail@dimitryivanov.ru) on 28.03.2015.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.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.OnTouchListenerCLIP_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, 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, 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, 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, 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_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 |
|---|
ScrollableLayout(android.content.Context context) |
ScrollableLayout(android.content.Context context,
android.util.AttributeSet attrs) |
ScrollableLayout(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr) |
| Modifier and Type | Method and Description |
|---|---|
android.animation.ValueAnimator |
animateScroll(int scrollY)
Helper method to animate scroll state of ScrollableLayout.
|
void |
computeScroll() |
protected int |
computeVerticalScrollRange() |
boolean |
dispatchTouchEvent(android.view.MotionEvent event) |
long |
getConsiderIdleMillis() |
int |
getMaxScrollY() |
protected int |
getNewY(int y) |
protected ScrollableScroller |
initScroller(android.content.Context context,
android.view.animation.Interpolator interpolator,
boolean flywheel)
Override this method if you wish to create own
Scroller |
boolean |
isAutoMaxScroll() |
boolean |
isSelfUpdateScroll() |
protected void |
onFinishInflate() |
protected void |
onLayout(boolean changed,
int left,
int top,
int right,
int bottom) |
void |
onRestoreInstanceState(android.os.Parcelable state) |
android.os.Parcelable |
onSaveInstanceState() |
void |
onScrollChanged(int l,
int t,
int oldL,
int oldT) |
protected void |
processAutoMaxScroll(boolean autoMaxScroll) |
void |
scrollTo(int x,
int y) |
void |
setAutoMaxScroll(boolean autoMaxScroll)
If set to true then ScrollableLayout will listen for global layout change of a view with
is passed through xml: scrollable_autoMaxScrollViewId OR first view in layout.
|
void |
setCanScrollVerticallyDelegate(CanScrollVerticallyDelegate delegate) |
void |
setCloseAnimatorConfigurator(CloseUpAnimatorConfigurator configurator) |
void |
setCloseUpAlgorithm(CloseUpAlgorithm closeUpAlgorithm)
Note that
DefaultCloseUpAlgorithm might be set with
xml definition ( app:scrollable_defaultCloseUp="true") |
void |
setCloseUpIdleAnimationTime(CloseUpIdleAnimationTime closeUpIdleAnimationTime)
Note that
SimpleCloseUpIdleAnimationTime might be set with xml definition
( app:scrollable_closeUpAnimationMillis="200") |
void |
setConsiderIdleMillis(long millis)
Note that this value might be set with xml definition (
app:scrollable_considerIdleMillis="100") |
void |
setDraggableView(android.view.View view)
Sets View which should be included in receiving scroll gestures.
|
void |
setFriction(float friction)
Sets friction for current
Scroller |
void |
setMaxScrollY(int maxY)
Also can be set via xml attribute
scrollable_maxScroll |
void |
setOnFlingOverListener(OnFlingOverListener onFlingOverListener) |
void |
setOnScrollChangedListener(OnScrollChangedListener listener)
Pass an
OnScrollChangedListener
if you wish to get notifications when scroll state of this View has changed. |
void |
setSelfUpdateScroll(boolean value)
Call this method to enable/disable scrolling logic.
|
checkLayoutParams, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, getAccessibilityClassName, getConsiderGoneChildrenWhenMeasuring, getMeasureAllChildren, onMeasure, setForegroundGravity, setMeasureAllChildren, shouldDelayChildPressedStateaddChildrenForAccessibility, addFocusables, 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, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, 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, hasFocusable, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAttachedToWindow, onCreateDrawableState, onDetachedFromWindow, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, updateViewLayoutaddFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceLayout, generateViewId, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getImportantForAccessibility, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineProvider, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getResources, 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, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInTouchMode, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDraw, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onOverScrolled, onPopulateAccessibilityEvent, onProvideStructure, onProvideVirtualStructure, onRtlPropertiesChanged, onScreenStateChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineProvider, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionName, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startNestedScroll, stopNestedScroll, toString, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDrawclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcanResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, requestFitSystemWindows, requestLayoutpublic ScrollableLayout(android.content.Context context)
public ScrollableLayout(android.content.Context context,
android.util.AttributeSet attrs)
public ScrollableLayout(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
protected void onFinishInflate()
onFinishInflate in class android.view.Viewprotected ScrollableScroller initScroller(android.content.Context context, android.view.animation.Interpolator interpolator, boolean flywheel)
Scrollercontext - Contextinterpolator - Interpolator, the default implementation passes nullflywheel - Scroller.Scroller(android.content.Context, android.view.animation.Interpolator, boolean)Scroller must not bu nullpublic void setFriction(float friction)
Scrollerfriction - to be appliedScroller.setFriction(float)public void setCanScrollVerticallyDelegate(CanScrollVerticallyDelegate delegate)
delegate - which will be invoked when scroll state of scrollable children is neededCanScrollVerticallyDelegatepublic void setMaxScrollY(int maxY)
scrollable_maxScrollmaxY - the max scroll y available for this View.getMaxScrollY()public int getMaxScrollY()
this View (aka header height)setMaxScrollY(int)public void setConsiderIdleMillis(long millis)
app:scrollable_considerIdleMillis="100")millis - millis after which current scroll
state would be considered idle and thus firing close up logic if setgetConsiderIdleMillis(),
DEFAULT_CONSIDER_IDLE_MILLISpublic long getConsiderIdleMillis()
setConsiderIdleMillis(long)public void setOnScrollChangedListener(OnScrollChangedListener listener)
OnScrollChangedListener
if you wish to get notifications when scroll state of this View has changed.
It\'s helpful for implementing own logic which depends on scroll state (e.g. parallax, alpha, etc)listener - to be invoked when onScrollChanged(int, int, int, int) has been called.
Might be null if you don\'t want to receive scroll notifications anymorepublic void setOnFlingOverListener(OnFlingOverListener onFlingOverListener)
public void onScrollChanged(int l,
int t,
int oldL,
int oldT)
onScrollChanged in class android.view.ViewView.onScrollChanged(int, int, int, int),
OnScrollChangedListener.onScrollChanged(int, int, int),
CloseUpAlgorithmpublic void setSelfUpdateScroll(boolean value)
value - indicating whether or not ScrollableLayout should process touch eventspublic boolean isSelfUpdateScroll()
setSelfUpdateScroll(boolean)public void setCloseUpAlgorithm(CloseUpAlgorithm closeUpAlgorithm)
DefaultCloseUpAlgorithm might be set with
xml definition ( app:scrollable_defaultCloseUp="true")closeUpAlgorithm - CloseUpAlgorithm implementation, might be nullCloseUpAlgorithm,
DefaultCloseUpAlgorithmpublic void setCloseUpIdleAnimationTime(CloseUpIdleAnimationTime closeUpIdleAnimationTime)
SimpleCloseUpIdleAnimationTime might be set with xml definition
( app:scrollable_closeUpAnimationMillis="200")closeUpIdleAnimationTime - CloseUpIdleAnimationTime implementation, might be nullCloseUpIdleAnimationTime,
SimpleCloseUpIdleAnimationTime,
DEFAULT_IDLE_CLOSE_UP_ANIMATIONpublic void setCloseAnimatorConfigurator(CloseUpAnimatorConfigurator configurator)
configurator - CloseUpAnimatorConfigurator implementation
to process current close up
ObjectAnimator, might be nullCloseUpAnimatorConfigurator,
ObjectAnimatorpublic android.animation.ValueAnimator animateScroll(int scrollY)
ValueAnimator is not fully configured -
it needs at least `duration` property.
Also, there is no checks if the current scrollY is equal to the requested one.scrollY - the final scroll y to animate toValueAnimator configured to animate scroll statepublic void scrollTo(int x,
int y)
scrollTo in class android.view.ViewView.scrollTo(int, int),
setCanScrollVerticallyDelegate(CanScrollVerticallyDelegate),
setMaxScrollY(int)public void setAutoMaxScroll(boolean autoMaxScroll)
autoMaxScroll - to listen for child view height and change mMaxScrollY accordinglypublic boolean isAutoMaxScroll()
setAutoMaxScroll(boolean)protected void processAutoMaxScroll(boolean autoMaxScroll)
protected int getNewY(int y)
public void setDraggableView(android.view.View view)
view - you wish to include in scrolling gestures (aka tabs)public boolean dispatchTouchEvent(android.view.MotionEvent event)
dispatchTouchEvent in class android.view.ViewGrouppublic void computeScroll()
computeScroll in class android.view.Viewprotected int computeVerticalScrollRange()
computeVerticalScrollRange in class android.view.Viewprotected void onLayout(boolean changed,
int left,
int top,
int right,
int bottom)
onLayout in class android.widget.FrameLayoutpublic android.os.Parcelable onSaveInstanceState()
onSaveInstanceState in class android.view.Viewpublic void onRestoreInstanceState(android.os.Parcelable state)
onRestoreInstanceState in class android.view.View