如图所示:
我在ScrollView里面嵌套了可以左右滑动的Viewpager,viewpager里面是上下滑动的
RecycleView,目前发现的问题是我给RecycleVIew设置的加载头显示不出来,最后一行也是显示不完全。感觉是滑动冲突的原因,但是网上没有系统的解决问题办法。请大家给点切实可行的解决办法吧
下面附上我的xml:
<?xml version="1.0" encoding="utf-8"?>
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rl_map_all"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--底部图层-->
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--底部图层-->
<!--右侧侧滑栏-->
<com.yinglan.scrolllayout.ScrollLayout
android:id="@+id/scroll_down_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00550033"
android:visibility="gone"
app:allowHorizontalScroll="true"
app:exitOffset="0dp"
app:isSupportExit="true"
app:maxOffset="300dp"
app:minOffset="50dp"
app:mode="open">
<!--多条记录悬浮-->
<com.yinglan.scrolllayout.content.ContentScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dimen1800"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<com.example.administrator.im_demo.ui.view.navigationbar.indicators.MagicIndicator
android:id="@+id/magic_indicator"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen120"
android:background="@color/tab_title" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_search_result"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<TextView
android:id="@+id/tv_next"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen110"
android:background="@color/white"
android:clickable="true"
android:gravity="center"
android:text="总共XX条记录"
android:textColor="@color/white"
android:textSize="@dimen/dimen32"
android:visibility="gone" />
</RelativeLayout>
</com.yinglan.scrolllayout.content.ContentScrollView>
</com.yinglan.scrolllayout.ScrollLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_mapall"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:titleTextColor="@android:color/white"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:visibility="gone"/>
<?xml version="1.0" encoding="utf-8"?>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white">
<com.wan7451.wanadapter.mylibrary.WanRecycleView
android:id="@+id/recycleview_float_company"
android:layout_width="match_parent"
android:layout_height="match_parent" />
下面是几个引用的view:
/*
*
- * sufly0001@gmail.com Modify the code to enhance the ease of use.
- *
- * Copyright (C) 2015 Ted xiong-wei@hotmail.com
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. * * */
package com.yinglan.scrolllayout.content;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewParent;
import android.widget.ScrollView;
import com.yinglan.scrolllayout.ScrollLayout;
public class ContentScrollView extends ScrollView {
public interface OnScrollChangedListener {
void onScrollChanged(int l, int t, int oldl, int oldt);
}
private OnScrollChangedListener listener;
public ContentScrollView(Context context) {
super(context);
}
public ContentScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ContentScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void setOnScrollChangeListener(OnScrollChangedListener listener) {
this.listener = listener;
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
listener.onScrollChanged(l, t, oldl, oldt);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
ViewParent parent = this.getParent();
while (parent != null) {
if (parent instanceof ScrollLayout) {
((ScrollLayout) parent).setAssociatedScrollView(this);
break;
}
parent = parent.getParent();
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
ViewParent parent = this.getParent();
if (parent instanceof ScrollLayout) {
if (((ScrollLayout) parent).getCurrentStatus() == ScrollLayout.Status.OPENED)
return false;
}
return super.onTouchEvent(ev);
}
}
package com.wan7451.wanadapter.mylibrary;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
/**
-
Created by Hello on 2015/6/30.
*/
public class WanRecycleView extends PullToRefreshBase {public WanRecycleView(Context context) {
super(context);
}public WanRecycleView(Context context, AttributeSet attrs) {
super(context, attrs);
}public WanRecycleView(Context context, Mode mode) {
super(context, mode);
}public WanRecycleView(Context context, Mode mode, AnimationStyle animStyle) {
super(context, mode, animStyle);
}@Override
public Orientation getPullToRefreshScrollDirection() {
return Orientation.VERTICAL;
}@Override
protected RecyclerView createRefreshableView(Context context, AttributeSet attrs) {
RecyclerView view = new RecyclerView(context, attrs);
view.setId(R.id.recycleView);
return view;
}@Override
protected boolean isReadyForPullEnd() {
int lastVisiblePosition = getRefreshableView().getChildAdapterPosition(getRefreshableView().getChildAt(getRefreshableView().getChildCount() -1));
if (lastVisiblePosition >= getRefreshableView().getAdapter().getItemCount()-1) {
return getRefreshableView().getChildAt(getRefreshableView().getChildCount() - 1).getBottom() <= getRefreshableView().getBottom();
}
return false;
}@Override
protected boolean isReadyForPullStart() {
if (getRefreshableView().getChildCount() <= 0)
return true;
int firstVisiblePosition = getRefreshableView().getChildAdapterPosition(getRefreshableView().getChildAt(0));
if (firstVisiblePosition == 0)
return getRefreshableView().getChildAt(0).getTop() == getRefreshableView().getPaddingTop();
else
return false;
}
}