SubtitleCoordinatorLayoutExample
SubtitleCoordinatorLayoutExample copied to clipboard
Question: How to make the title&subtitle change their sizes according to scroll value?
Just like the native library does...
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.