SubtitleCoordinatorLayoutExample icon indicating copy to clipboard operation
SubtitleCoordinatorLayoutExample copied to clipboard

Question: How to make the title&subtitle change their sizes according to scroll value?

Open AndroidDeveloperLB opened this issue 10 years ago • 1 comments

Just like the native library does...

AndroidDeveloperLB avatar Nov 10 '15 12:11 AndroidDeveloperLB

In order to change the size of title add following code:

ViewBehavior.java

    // Define constant
    private static final float MAX_SCALE = 0.5f;        

    // Inside onDependentViewChanged method set scale for the title
    float size = ((1 - percentage) * MAX_SCALE) + 1;
    child.setScaleXTitle(size);
    child.setScaleYTitle(size);

HeaderView.java - Add following methods

public void setScaleXTitle(float scaleXTitle) {
    title.setScaleX(scaleXTitle);
    title.setPivotX(0);
}

public void setScaleYTitle(float scaleYTitle) {
    title.setScaleY(scaleYTitle);
    title.setPivotY(30);
}

For complete code follow this link: http://stackoverflow.com/a/34197613/1709595

This will only re-size title with scroll. You can use the same method to re-size subtitle too.

prashantkedia avatar Dec 10 '15 09:12 prashantkedia