[/code] Как вы видите Swiperefresh есть Android: paddingTop = "? attr/actionBarsize" , как вы видите, у меня есть Quickhideappbarbehavior для Appbar: [code]public class QuickHideAppBarBehavior extends QuickHideBehavior {
private int mActionBarHeight;
//Required to instantiate as a default behavior @SuppressWarnings("unused") public QuickHideAppBarBehavior() { }
//Required to attach behavior via XML @SuppressWarnings("unused") public QuickHideAppBarBehavior(Context context, AttributeSet attrs) { super(context, attrs); // Calculate ActionBar height mActionBarHeight = getActionBarHeight(context); }
//Required to instantiate as a default behavior public QuickHideBehavior() { }
//Required to attach behavior via XML public QuickHideBehavior(Context context, AttributeSet attrs) { super(context, attrs); mVelocity = (int) (ViewConfiguration.get(context).getScaledMaximumFlingVelocity() / 3.5f); }
//Called before a nested scroll event. Return true to declare interest @Override public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View directTargetChild, @NonNull View target, int nestedScrollAxes, int type) { //We have to declare interest in the scroll to receive further events return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; }
//Called after the scrolling child handles the fling @Override public boolean onNestedFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View target, float velocityX, float velocityY, boolean consumed) { //We only care when the target view is already handling the fling if (consumed) { if (velocityY > 0 && mScrollTrigger != DIRECTION_UP && velocityY > mVelocity && coordinatorLayout.findViewById(R.id.recyclerView).canScrollVertically(1)) { mScrollTrigger = DIRECTION_UP; restartAnimator(child, getTargetHideValue(coordinatorLayout, child)); removeSpace(target); } else if (velocityY < 0 && mScrollTrigger != DIRECTION_DOWN && velocityY < (float) -mVelocity / 2) { mScrollTrigger = DIRECTION_DOWN; restartAnimator(child, 0f); addSpace(target); } } return false; }
mAnimator = ObjectAnimator .ofFloat(target, View.TRANSLATION_Y, value) .setDuration(250); mAnimator.start(); } } < /code> Проблема в том, что я использовал накладку, так как я хочу, чтобы приложение работало по обеим ориентации, у Swiperefreshlayout не хватает места сверху, поэтому я должен использовать: < /p> binding.swipeRefresh.setProgressViewOffset(true, 0, getActionBarHeight(requireContext()) + SWIPE_REFRESH_OFFSET); [/code] Интересно, есть ли обходные пути, чтобы избежать использования setprogressviewoffset и использовать поведение по умолчанию Swiperefresh?>