Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关闭滑动后ViewPager怎么变成透明了 #48

Open
gmfbilu opened this issue Dec 26, 2016 · 2 comments
Open

关闭滑动后ViewPager怎么变成透明了 #48

gmfbilu opened this issue Dec 26, 2016 · 2 comments

Comments

@gmfbilu
Copy link

gmfbilu commented Dec 26, 2016

No description provided.

@Paul-KK
Copy link

Paul-KK commented Dec 31, 2016

最新代码确实存在这个问题,主要是SwipeBackPage.java这个类中的onPostCreate方法发生变化,附上我修改的代码。

package com.jude.swipbackhelper;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.ViewGroup;

/**

  • Created by Mr.Jude on 2015/8/3. 每个滑动页面的管理
    */
    public class SwipeBackPage {
    Activity mActivity;
    SwipeBackLayout mSwipeBackLayout;
    RelateSlider slider;

    SwipeBackPage(Activity activity) {
    this.mActivity = activity;
    }

    // 页面的回调用于配置滑动效果
    void onCreate() {
    mActivity.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mActivity.getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT);

     mSwipeBackLayout = new SwipeBackLayout(mActivity);
     mSwipeBackLayout.setLayoutParams(
     		new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
     slider = new RelateSlider(this);
    

    }

    void onPostCreate() {
    mSwipeBackLayout.attachToActivity(mActivity);
    }

    public SwipeBackPage setSwipeRelateEnable(boolean enable) {
    slider.setEnable(enable);
    return this;
    }

    public SwipeBackPage setSwipeRelateOffset(int offset) {
    slider.setOffset(offset);
    return this;
    }

    /**

    • 是否可滑动【activity的onWindowFocusChanged之前】调用本方法,
    • 之后请调用{@link #setSwipeBackEnableAfteronWindowFocusChanged()}
      */
      public SwipeBackPage setSwipeBackEnableBeforeonWindowFocusChanged(boolean enable) {
      if (enable) {
      mSwipeBackLayout.attachToActivity(mActivity);
      } else {
      mSwipeBackLayout.removeFromActivity(mActivity);
      }
      mSwipeBackLayout.setEnableGesture(enable);
      return this;
      }

    /**

    • 是否可滑动【activity的onWindowFocusChanged之后】调用本方法,
    • 之前请调用{@link #setSwipeBackEnableBeforeonWindowFocusChanged()}
    • 如果在onWindowFocusChanged之后调用{@link #setSwipeBackEnableBeforeonWindowFocusChanged()},
    • 则会使某些View如Switch的isLaidOut()函数始终为false,导致动画丢失
      */
      public SwipeBackPage setSwipeBackEnableAfteronWindowFocusChanged(boolean enable) {
      mSwipeBackLayout.setEnableGesture(enable);
      return this;
      }

    // 可滑动的范围。百分比。200表示为左边200px的屏幕
    public SwipeBackPage setSwipeEdge(int swipeEdge) {
    mSwipeBackLayout.setEdgeSize(swipeEdge);
    return this;
    }

    // 可滑动的范围。百分比。0.2表示为左边20%的屏幕
    public SwipeBackPage setSwipeEdgePercent(float swipeEdgePercent) {
    mSwipeBackLayout.setEdgeSizePercent(swipeEdgePercent);
    return this;
    }

    // 对横向滑动手势的敏感程度。0为迟钝 1为敏感
    public SwipeBackPage setSwipeSensitivity(float sensitivity) {
    mSwipeBackLayout.setSensitivity(mActivity, sensitivity);
    return this;
    }

    // 底层阴影颜色
    public SwipeBackPage setScrimColor(int color) {
    mSwipeBackLayout.setScrimColor(color);
    return this;
    }

    // 触发关闭Activity百分比
    public SwipeBackPage setClosePercent(float percent) {
    mSwipeBackLayout.setScrollThreshold(percent);
    return this;
    }

    public SwipeBackPage setDisallowInterceptTouchEvent(boolean disallowIntercept) {
    mSwipeBackLayout.setDisallowInterceptTouchEvent(disallowIntercept);
    return this;
    }

    public SwipeBackPage addListener(SwipeListener listener) {
    mSwipeBackLayout.addSwipeListener(listener);
    return this;
    }

    public SwipeBackPage removeListener(SwipeListener listener) {
    mSwipeBackLayout.removeSwipeListener(listener);
    return this;
    }

    public SwipeBackLayout getSwipeBackLayout() {
    return mSwipeBackLayout;
    }

    public void scrollToFinishActivity() {
    mSwipeBackLayout.scrollToFinishActivity();
    }

}

@Jude95
Copy link
Owner

Jude95 commented Jan 2, 2017

@gmfbilu 如何复现?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants