Browse Source

[액션바][Bug] API23 미만에서 스크롤 안되는 버그 수정

hyodong.min 6 years ago
parent
commit
9c3e6a958e

+ 2 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/helper/ActionBarHelper.java

@@ -270,7 +270,7 @@ public class ActionBarHelper extends Helper {
     else if (isScrollable) {
       // 스크롤 플래그 설정
       toolbarLayoutParams.setScrollFlags(APP_BAR_LAYOUT_SCROLL_PARAM);
-      toolbarLayoutParams.height = ResourceUtil.getDimension(R.dimen.action_bar_height);
+//      toolbarLayoutParams.height = ResourceUtil.getDimension(R.dimen.action_bar_height);
 
       appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
       containerLayoutParams.setBehavior(null);
@@ -279,7 +279,7 @@ public class ActionBarHelper extends Helper {
     else {
       toolbarLayoutParams.setScrollFlags(0);
       // 스테이터스바 아래 ui 가 눌리지 않아서 높이를 조절
-      toolbarLayoutParams.height = ResourceUtil.getDimension(R.dimen.action_bar_height);
+//      toolbarLayoutParams.height = ResourceUtil.getDimension(R.dimen.action_bar_height);
 
       appBarLayoutParams.setBehavior(null);
       containerLayoutParams.setBehavior(null);

+ 6 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/CustomHeaderBehavior.java

@@ -38,8 +38,9 @@ public class CustomHeaderBehavior extends AppBarLayout.Behavior {
 //    Log.i("APP# CustomHeaderBehavior | onStartNestedScroll", "|" + " directTargetChild: " + directTargetChild);
 //    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;
+//    super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type);
+    // 항상 스크롤
+    return true;
   }
 
   private boolean isUp = false;
@@ -72,7 +73,9 @@ public class CustomHeaderBehavior extends AppBarLayout.Behavior {
     if (Math.abs(dy) > 10) {
       if (dy > 0 && isUp == false) {
         isUp = true;
-        ObjectAnimator animation = ObjectAnimator.ofFloat(child, "translationY", -child.getHeight() - ResourceUtil.getStatusBarHeightManual());
+        float ty = -child.getHeight() - ResourceUtil.getStatusBarHeightManual();
+//        Log.i("APP# CustomHeaderBehavior | onNestedPreScroll", "|" + " ty --> " + ty);
+        ObjectAnimator animation = ObjectAnimator.ofFloat(child, "translationY", ty);
         animation.setDuration(600);
         animation.start();
       }