diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java index 131225053b..0b5de590fe 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java @@ -157,10 +157,21 @@ private void initAttrs(Context context, AttributeSet attrs) { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - mTargetView = getChildAt(0); - setRefreshView(); + if(mTargetView == null && getChildCount() > 0){ + mTargetView = getChildAt(0); + } + if(mTargetView != null){ + if(headerView == null || footerView == null){ + setRefreshView(); + } + } } + + public void addTargetView(View mInnerView){ + this.addView(mInnerView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); + setRefreshView(); + } /** * Init refresh view or loading view */ diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java index c8c25dc192..2319f8c9ed 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java @@ -96,7 +96,7 @@ private WXSwipeLayout createBounceView(Context context) { mInnerView = setInnerView(context); if (mInnerView == null) return null; - swipeLayout.addView(mInnerView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); + swipeLayout.addTargetView(mInnerView); addView(swipeLayout, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return swipeLayout; }