From 0e16be23a4e3434ee32292a006a12accc1096955 Mon Sep 17 00:00:00 2001 From: cgspine Date: Thu, 2 Aug 2018 20:00:09 +0800 Subject: [PATCH] bugfix: should call requestApplyInsets when addView is called in QMUIViewPager. #352 --- .../java/com/qmuiteam/qmui/widget/QMUIViewPager.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qmui/src/main/java/com/qmuiteam/qmui/widget/QMUIViewPager.java b/qmui/src/main/java/com/qmuiteam/qmui/widget/QMUIViewPager.java index cab1dd81d..d440ba723 100644 --- a/qmui/src/main/java/com/qmuiteam/qmui/widget/QMUIViewPager.java +++ b/qmui/src/main/java/com/qmuiteam/qmui/widget/QMUIViewPager.java @@ -1,19 +1,17 @@ package com.qmuiteam.qmui.widget; -import android.annotation.TargetApi; import android.content.Context; import android.database.DataSetObserver; import android.graphics.Rect; import android.os.Build; import android.os.Parcelable; import android.support.v4.view.PagerAdapter; +import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewPager; -import android.support.v4.view.WindowInsetsCompat; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.view.WindowInsets; import com.qmuiteam.qmui.util.QMUIWindowInsetHelper; @@ -66,6 +64,12 @@ public void setEnableLoop(boolean enableLoop) { } + @Override + public void addView(View child, int index, ViewGroup.LayoutParams params) { + super.addView(child, index, params); + ViewCompat.requestApplyInsets(this); + } + @Override public boolean onTouchEvent(MotionEvent ev) { return mIsSwipeable && super.onTouchEvent(ev);