Class SubtitleCollapsingToolbarLayout

    • Constructor Detail

      • SubtitleCollapsingToolbarLayout

        public SubtitleCollapsingToolbarLayout​(@NonNull
                                               Context context)
      • SubtitleCollapsingToolbarLayout

        public SubtitleCollapsingToolbarLayout​(@NonNull
                                               Context context,
                                               @Nullable
                                               AttributeSet attrs)
      • SubtitleCollapsingToolbarLayout

        public SubtitleCollapsingToolbarLayout​(@NonNull
                                               Context context,
                                               @Nullable
                                               AttributeSet attrs,
                                               int defStyleAttr)
    • Method Detail

      • draw

        public void draw​(@NonNull
                         Canvas canvas)
        Overrides:
        draw in class View
      • onSizeChanged

        protected void onSizeChanged​(int w,
                                     int h,
                                     int oldw,
                                     int oldh)
        Overrides:
        onSizeChanged in class View
      • onMeasure

        protected void onMeasure​(int widthMeasureSpec,
                                 int heightMeasureSpec)
        Overrides:
        onMeasure in class FrameLayout
      • onLayout

        protected void onLayout​(boolean changed,
                                int left,
                                int top,
                                int right,
                                int bottom)
        Overrides:
        onLayout in class FrameLayout
      • getTitle

        @Nullable
        public CharSequence getTitle()
        Returns the title currently being displayed by this view. If the title is not enabled, then this will return null.
      • getSubtitle

        @Nullable
        public CharSequence getSubtitle()
        Returns the subtitle currently being displayed by this view. If the title is not enabled, then this will return null.
      • isTitleEnabled

        public boolean isTitleEnabled()
        Returns whether this view is currently displaying its own title and subtitle.
        See Also:
        setTitleEnabled(boolean)
      • setScrimsShown

        public void setScrimsShown​(boolean shown)
        Set whether the content scrim and/or status bar scrim should be shown or not. Any change in the vertical scroll may overwrite this value. Any visibility change will be animated if this view has already been laid out.
        Parameters:
        shown - whether the scrims should be shown
        See Also:
        getStatusBarScrim(), getContentScrim()
      • setScrimsShown

        public void setScrimsShown​(boolean shown,
                                   boolean animate)
        Set whether the content scrim and/or status bar scrim should be shown or not. Any change in the vertical scroll may overwrite this value.
        Parameters:
        shown - whether the scrims should be shown
        animate - whether to animate the visibility change
        See Also:
        getStatusBarScrim(), getContentScrim()
      • setContentScrim

        public void setContentScrim​(@Nullable
                                    Drawable drawable)
        Set the drawable to use for the content scrim from resources. Providing null will disable the scrim functionality.
        Parameters:
        drawable - the drawable to display
        See Also:
        getContentScrim()
      • setContentScrimColor

        public void setContentScrimColor​(int color)
        Set the color to use for the content scrim.
        Parameters:
        color - the color to display
        See Also:
        getContentScrim()
      • setContentScrimResource

        public void setContentScrimResource​(@DrawableRes
                                            int resId)
        Set the drawable to use for the content scrim from resources.
        Parameters:
        resId - drawable resource id
        See Also:
        getContentScrim()
      • setStatusBarScrim

        public void setStatusBarScrim​(@Nullable
                                      Drawable drawable)
        Set the drawable to use for the status bar scrim from resources. Providing null will disable the scrim functionality.

        This scrim is only shown when we have been given a top system inset.

        Parameters:
        drawable - the drawable to display
        See Also:
        getStatusBarScrim()
      • setVisibility

        public void setVisibility​(int visibility)
        Overrides:
        setVisibility in class View
      • setStatusBarScrimColor

        public void setStatusBarScrimColor​(int color)
        Set the color to use for the status bar scrim.

        This scrim is only shown when we have been given a top system inset.

        Parameters:
        color - the color to display
        See Also:
        getStatusBarScrim()
      • setStatusBarScrimResource

        public void setStatusBarScrimResource​(@DrawableRes
                                              int resId)
        Set the drawable to use for the content scrim from resources.
        Parameters:
        resId - drawable resource id
        See Also:
        getStatusBarScrim()
      • setCollapsedTitleTextAppearance

        public void setCollapsedTitleTextAppearance​(@StyleRes
                                                    int resId)
        Sets the text color and size for the collapsed title from the specified TextAppearance resource.
      • setCollapsedSubtitleTextAppearance

        public void setCollapsedSubtitleTextAppearance​(@StyleRes
                                                       int resId)
        Sets the text color and size for the collapsed subtitle from the specified TextAppearance resource.
      • setCollapsedTitleTextColor

        public void setCollapsedTitleTextColor​(int color)
        Sets the text color of the collapsed title.
        Parameters:
        color - The new text color in ARGB format
      • setCollapsedSubtitleTextColor

        public void setCollapsedSubtitleTextColor​(int color)
        Sets the text color of the collapsed subtitle.
        Parameters:
        color - The new text color in ARGB format
      • setCollapsedTitleTextColor

        public void setCollapsedTitleTextColor​(@NonNull
                                               ColorStateList colors)
        Sets the text colors of the collapsed title.
        Parameters:
        colors - ColorStateList containing the new text colors
      • setCollapsedSubtitleTextColor

        public void setCollapsedSubtitleTextColor​(@NonNull
                                                  ColorStateList colors)
        Sets the text colors of the collapsed subtitle.
        Parameters:
        colors - ColorStateList containing the new text colors
      • setCollapsedTitleGravity

        public void setCollapsedTitleGravity​(int gravity)
        Sets the horizontal alignment of the collapsed title and the vertical gravity that will be used when there is extra space in the collapsed bounds beyond what is required for the title itself.
      • getCollapsedTitleGravity

        public int getCollapsedTitleGravity()
        Returns the horizontal and vertical alignment for title when collapsed.
      • setExpandedTitleTextAppearance

        public void setExpandedTitleTextAppearance​(@StyleRes
                                                   int resId)
        Sets the text color and size for the expanded title from the specified TextAppearance resource.
      • setExpandedSubtitleTextAppearance

        public void setExpandedSubtitleTextAppearance​(@StyleRes
                                                      int resId)
        Sets the text color and size for the expanded subtitle from the specified TextAppearance resource.
      • setExpandedTitleTextColor

        public void setExpandedTitleTextColor​(int color)
        Sets the text color of the expanded title.
        Parameters:
        color - The new text color in ARGB format
      • setExpandedSubtitleTextColor

        public void setExpandedSubtitleTextColor​(int color)
        Sets the text color of the expanded subtitle.
        Parameters:
        color - The new text color in ARGB format
      • setExpandedTitleTextColor

        public void setExpandedTitleTextColor​(@NonNull
                                              ColorStateList colors)
        Sets the text colors of the expanded title.
        Parameters:
        colors - ColorStateList containing the new text colors
      • setExpandedSubtitleTextColor

        public void setExpandedSubtitleTextColor​(@NonNull
                                                 ColorStateList colors)
        Sets the text colors of the expanded subtitle.
        Parameters:
        colors - ColorStateList containing the new text colors
      • setExpandedTitleGravity

        public void setExpandedTitleGravity​(int gravity)
        Sets the horizontal alignment of the expanded title and the vertical gravity that will be used when there is extra space in the expanded bounds beyond what is required for the title itself.
      • getExpandedTitleGravity

        public int getExpandedTitleGravity()
        Returns the horizontal and vertical alignment for title when expanded.
      • setCollapsedTitleTypeface

        public void setCollapsedTitleTypeface​(@Nullable
                                              Typeface typeface)
        Set the typeface to use for the collapsed title.
        Parameters:
        typeface - typeface to use, or null to use the default.
      • setCollapsedSubtitleTypeface

        public void setCollapsedSubtitleTypeface​(@Nullable
                                                 Typeface typeface)
        Set the typeface to use for the collapsed title.
        Parameters:
        typeface - typeface to use, or null to use the default.
      • getCollapsedTitleTypeface

        @NonNull
        public Typeface getCollapsedTitleTypeface()
        Returns the typeface used for the collapsed title.
      • getCollapsedSubtitleTypeface

        @NonNull
        public Typeface getCollapsedSubtitleTypeface()
        Returns the typeface used for the collapsed title.
      • setExpandedTitleTypeface

        public void setExpandedTitleTypeface​(@Nullable
                                             Typeface typeface)
        Set the typeface to use for the expanded title.
        Parameters:
        typeface - typeface to use, or null to use the default.
      • setExpandedSubtitleTypeface

        public void setExpandedSubtitleTypeface​(@Nullable
                                                Typeface typeface)
        Set the typeface to use for the expanded title.
        Parameters:
        typeface - typeface to use, or null to use the default.
      • getExpandedTitleTypeface

        @NonNull
        public Typeface getExpandedTitleTypeface()
        Returns the typeface used for the expanded title.
      • getExpandedSubtitleTypeface

        @NonNull
        public Typeface getExpandedSubtitleTypeface()
        Returns the typeface used for the expanded title.
      • getExpandedTitleMarginStart

        public int getExpandedTitleMarginStart()
        Returns:
        the starting expanded title margin in pixels
        See Also:
        setExpandedTitleMarginStart(int)
      • setExpandedTitleMarginStart

        public void setExpandedTitleMarginStart​(int margin)
        Sets the starting expanded title margin in pixels.
        Parameters:
        margin - the starting title margin in pixels
        See Also:
        getExpandedTitleMarginStart()
      • getExpandedTitleMarginTop

        public int getExpandedTitleMarginTop()
        Returns:
        the top expanded title margin in pixels
        See Also:
        setExpandedTitleMarginTop(int)
      • setExpandedTitleMarginTop

        public void setExpandedTitleMarginTop​(int margin)
        Sets the top expanded title margin in pixels.
        Parameters:
        margin - the top title margin in pixels
        See Also:
        getExpandedTitleMarginTop()
      • getExpandedTitleMarginEnd

        public int getExpandedTitleMarginEnd()
        Returns:
        the ending expanded title margin in pixels
        See Also:
        setExpandedTitleMarginEnd(int)
      • setExpandedTitleMarginEnd

        public void setExpandedTitleMarginEnd​(int margin)
        Sets the ending expanded title margin in pixels.
        Parameters:
        margin - the ending title margin in pixels
        See Also:
        getExpandedTitleMarginEnd()
      • getExpandedTitleMarginBottom

        public int getExpandedTitleMarginBottom()
        Returns:
        the bottom expanded title margin in pixels
        See Also:
        setExpandedTitleMarginBottom(int)
      • setExpandedTitleMarginBottom

        public void setExpandedTitleMarginBottom​(int margin)
        Sets the bottom expanded title margin in pixels.
        Parameters:
        margin - the bottom title margin in pixels
        See Also:
        getExpandedTitleMarginBottom()
      • setScrimVisibleHeightTrigger

        public void setScrimVisibleHeightTrigger​(int height)
        Set the amount of visible height in pixels used to define when to trigger a scrim visibility change.

        If the visible height of this view is less than the given value, the scrims will be made visible, otherwise they are hidden.

        Parameters:
        height - value in pixels used to define when to trigger a scrim visibility change
      • getScrimVisibleHeightTrigger

        public int getScrimVisibleHeightTrigger()
        Returns the amount of visible height in pixels used to define when to trigger a scrim visibility change.
        See Also:
        setScrimVisibleHeightTrigger(int)
      • setScrimAnimationDuration

        public void setScrimAnimationDuration​(long duration)
        Set the duration used for scrim visibility animations.
        Parameters:
        duration - the duration to use in milliseconds
      • getScrimAnimationDuration

        public long getScrimAnimationDuration()
        Returns the duration in milliseconds used for scrim visibility animations.