Android CoordinatorLayout+RecyclerView升级targetSdk26上啦更多延迟加载

targetSdk从23升级26

将项目由targetSdk23升级至26导致RecyclerView展示出现空白行间距过大问题

解决方案:将item的layout设置成wrap_content即可

CoordinatorLayout+RecyclerView上啦更多loading延迟出现

细心的朋友会发现上啦更多的时候出现1-2S的延迟才出现loading图然后进行加载

解决方案:


public class FixAppBarLayoutBehaviorextends AppBarLayout.Behavior{

public FixAppBarLayoutBehavior() {

super();

}

public FixAppBarLayoutBehavior(Context context, AttributeSet attrs) {

super(context, attrs);

}

@Override

    public void onNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,int dxConsumed,int dyConsumed,int dxUnconsumed,int dyUnconsumed,int type) {

super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);

stopNestedScrollIfNeeded(dyUnconsumed, child, target, type);

}

@Override

    public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,int dx,int dy,int[] consumed,int type) {

super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);

stopNestedScrollIfNeeded(dy, child, target, type);

}

private void stopNestedScrollIfNeeded(int dy, AppBarLayout child, View target,int type) {

if (type == ViewCompat.TYPE_NON_TOUCH) {

final int currOffset = getTopAndBottomOffset();

if ((dy <0 && currOffset ==0) || (dy >0 && currOffset == -child.getTotalScrollRange())) {

ViewCompat.stopNestedScroll(target, ViewCompat.TYPE_NON_TOUCH);

}

}

}

}

就可以滑动如斯了

CoordinatorLayout和导航栏重叠

解决方案:

    android:fitsSystemWindows="true"

即可。

你可能感兴趣的:(Android CoordinatorLayout+RecyclerView升级targetSdk26上啦更多延迟加载)