ikew0ng / SwipeBackLayout

An Android library that help you to build app with swipe back gesture.
Apache License 2.0
6.13k stars 1.4k forks source link

滑动返回触发后,又取消滑动返回,退出动画会失效 #192

Open leeyushi opened 4 years ago

leeyushi commented 4 years ago

版本是: me.imid.swipebacklayout.lib:library:1.3.0 退出的动画: @Override public void finish() { super.finish(); overridePendingTransition(R.anim.tran_enter_out, R.anim.tran_exit_out); } R.anim.tran_enter_out代码: <?xml version="1.0" encoding="utf-8"?>

R.anim.tran_exit_out代码: <?xml version="1.0" encoding="utf-8"?>

如果触发侧滑返回(从左边向右轻微拖动,然后再取消)只有R.anim.tran_exit_out的代码块会被执行到,R.anim.tran_enter_out不会执行,如果不触发侧滑返回,则两个都会执行到 测试环境: oppoR15真机,模拟器都会必现

leeyushi commented 4 years ago

R.anim.tran_enter_out代码: <?xml version="1.0" encoding="utf-8"?>

image R.anim.tran_exit_out代码: <?xml version="1.0" encoding="utf-8"?>

image

第一个楼层的代码被吞掉了,我又补发了一下代码,顺带截图了,如果还被吞掉,就只能参考代码截图了

wangtonggen commented 3 years ago

这个解决没

lzls commented 2 years ago

取消滑动返回时,将activity 设置回不透明即可解决

注意只有当Activity使用了非窗口透明的主题时才这么做,通过以下代码判断:


    /**
     * Determines whether the current Window is translucent or floating by default, according to
     * the {@link android.R.attr#windowIsFloating} and {@link android.R.attr#windowIsTranslucent}
     * attributes set in its theme.
     */
    public static boolean isWindowTranslucentOrFloatingTheme(Window window) {
        try {
            @SuppressLint("PrivateApi")
            Class<?> styleableClass =
                    window.getContext().getClassLoader()
                            .loadClass("com.android.internal.R$styleable");
            return getWindowStyleBoolean(window, styleableClass, "Window_windowIsTranslucent", false)
                    || getWindowStyleBoolean(window, styleableClass, "Window_windowIsFloating", false);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    private static boolean getWindowStyleBoolean(
            Window window,
            Class<?> styleableClass,
            String attrIndexName,
            @SuppressWarnings("SameParameterValue") boolean defValue) throws Exception {
        return window
                .getWindowStyle()
                .getBoolean(styleableClass.getField(attrIndexName).getInt(styleableClass), defValue);
    }