|
|
@@ -3,6 +3,7 @@
|
|
|
*/
|
|
|
package kr.co.zumo.app.lifeplus.view;
|
|
|
|
|
|
+import android.animation.ObjectAnimator;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.design.widget.AppBarLayout;
|
|
|
import android.support.design.widget.CoordinatorLayout;
|
|
|
@@ -36,8 +37,10 @@ public class CustomHeaderBehavior extends AppBarLayout.Behavior {
|
|
|
// Log.i("APP# CustomHeaderBehavior | onStartNestedScroll", "|" + " target: " + target);
|
|
|
// Log.i("APP# CustomHeaderBehavior | onStartNestedScroll", "|" + " nestedScrollAxes: " + nestedScrollAxes);
|
|
|
return super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type);
|
|
|
+// return false;
|
|
|
}
|
|
|
|
|
|
+ private boolean isUp = false;
|
|
|
|
|
|
@Override
|
|
|
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed, int type) {
|
|
|
@@ -59,11 +62,26 @@ public class CustomHeaderBehavior extends AppBarLayout.Behavior {
|
|
|
// consumed[1] = 0;
|
|
|
// }
|
|
|
// }
|
|
|
- super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
|
|
|
+// super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
|
|
|
|
|
|
// Log.w("APP# CustomHeaderBehavior | onNestedPreScroll", "|" + " target: " + target);
|
|
|
// Log.i("APP# CustomHeaderBehavior | onNestedPreScroll", "| consumed: " + Arrays.toString(consumed));
|
|
|
|
|
|
+ if (Math.abs(dy) > 10) {
|
|
|
+ if (dy > 0 && isUp == false) {
|
|
|
+ isUp = true;
|
|
|
+ ObjectAnimator animation = ObjectAnimator.ofFloat(child, "translationY", -child.getHeight());
|
|
|
+ animation.setDuration(600);
|
|
|
+ animation.start();
|
|
|
+ }
|
|
|
+ else if (dy < 0 && isUp) {
|
|
|
+ isUp = false;
|
|
|
+ ObjectAnimator animation = ObjectAnimator.ofFloat(child, "translationY", 0f);
|
|
|
+ animation.setDuration(400);
|
|
|
+ animation.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* appbarlayout 이 스크롤되는 동안에도 consume 은 하지 않아 nested scroller 도 함께 스크롤된다.
|
|
|
*/
|