Package 

Class OrientationHelper


  • 
    public abstract class OrientationHelper
    
                        

    Helper class for LayoutManagers to abstract measurements depending on the View's orientation.

    It is developed to easily support vertical and horizontal orientations in a LayoutManager but can also be used to abstract calls around view bounds and child measurements with margins and decorations.

    • Method Detail

      • onLayoutComplete

         void onLayoutComplete()

        Call this method after onLayout method is complete if state is NOT pre-layout.This method records information like layout bounds that might be useful in the next layoutcalculations.

      • getDecoratedStart

         abstract int getDecoratedStart(View view)

        Returns the start of the view including its decoration and margin.

        For example, for the horizontal helper, if a View's left is at pixel 20, has 2px leftdecoration and 3px left margin, returned value will be 15px.

        Parameters:
        view - The view element to check
      • getDecoratedEnd

         abstract int getDecoratedEnd(View view)

        Returns the end of the view including its decoration and margin.

        For example, for the horizontal helper, if a View's right is at pixel 200, has 2px rightdecoration and 3px right margin, returned value will be 205.

        Parameters:
        view - The view element to check
      • getTransformedEndWithDecoration

         abstract int getTransformedEndWithDecoration(View view)

        Returns the end of the View after its matrix transformations are applied to its layoutposition.

        This method is useful when trying to detect the visible edge of a View.

        It includes the decorations but does not include the margins.

        Parameters:
        view - The view whose transformed end will be returned
      • getTransformedStartWithDecoration

         abstract int getTransformedStartWithDecoration(View view)

        Returns the start of the View after its matrix transformations are applied to its layoutposition.

        This method is useful when trying to detect the visible edge of a View.

        It includes the decorations but does not include the margins.

        Parameters:
        view - The view whose transformed start will be returned
      • getDecoratedMeasurement

         abstract int getDecoratedMeasurement(View view)

        Returns the space occupied by this View in the current orientation including decorations andmargins.

        Parameters:
        view - The view element to check
      • getDecoratedMeasurementInOther

         abstract int getDecoratedMeasurementInOther(View view)

        Returns the space occupied by this View in the perpendicular orientation includingdecorations and margins.

        Parameters:
        view - The view element to check
      • getStartAfterPadding

         abstract int getStartAfterPadding()

        Returns the start position of the layout after the start padding is added.

      • getEndAfterPadding

         abstract int getEndAfterPadding()

        Returns the end position of the layout after the end padding is removed.

      • getEnd

         abstract int getEnd()

        Returns the end position of the layout without taking padding into account.

      • offsetChildren

         abstract void offsetChildren(int amount)

        Offsets all children's positions by the given amount.

        Parameters:
        amount - Value to add to each child's layout parameters
      • offsetChild

         abstract void offsetChild(View view, int offset)

        Offsets the child in this orientation.

        Parameters:
        view - View to offset
        offset - offset amount
      • getEndPadding

         abstract int getEndPadding()

        Returns the padding at the end of the layout. For horizontal helper, this is the rightpadding and for vertical helper, this is the bottom padding. This method does not checkwhether the layout is RTL or not.

      • getMode

         abstract int getMode()

        Returns the MeasureSpec mode for the current orientation from the LayoutManager.

      • getModeInOther

         abstract int getModeInOther()

        Returns the MeasureSpec mode for the perpendicular orientation from the LayoutManager.