Optimized FoldLayout: Set default status is hide.

This commit is contained in:
2022-04-18 14:22:12 +08:00
parent 43c6fd91db
commit d3112fb57e

View File

@@ -86,9 +86,11 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener {
int contentHeight = content.getMeasuredHeight(); int contentHeight = content.getMeasuredHeight();
if (!init) { if (!init) {
LayoutParams layoutParams = (LayoutParams) content.getLayoutParams();
layoutParams.height = 0;
content.setLayoutParams(layoutParams);
showAnimator = ValueAnimator.ofInt(0, contentHeight); showAnimator = ValueAnimator.ofInt(0, contentHeight);
showAnimator.addUpdateListener(animation -> { showAnimator.addUpdateListener(animation -> {
LayoutParams layoutParams = (LayoutParams) content.getLayoutParams();
layoutParams.height = (int) animation.getAnimatedValue(); layoutParams.height = (int) animation.getAnimatedValue();
content.setLayoutParams(layoutParams); content.setLayoutParams(layoutParams);
}); });
@@ -103,7 +105,6 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener {
hideAnimator = ValueAnimator.ofInt(contentHeight, 0); hideAnimator = ValueAnimator.ofInt(contentHeight, 0);
hideAnimator.addUpdateListener(animation -> { hideAnimator.addUpdateListener(animation -> {
LayoutParams layoutParams = (LayoutParams) content.getLayoutParams();
layoutParams.height = (int) animation.getAnimatedValue(); layoutParams.height = (int) animation.getAnimatedValue();
content.setLayoutParams(layoutParams); content.setLayoutParams(layoutParams);
}); });
@@ -119,8 +120,6 @@ public class FoldLayout extends LinearLayout implements View.OnClickListener {
} }
}); });
init = true; init = true;
showItem();
} }
} }