uni-app swiper-list 兼容 transparent 模式问题 安卓设置 setSpecialEffects 无效

uni-app swiper-list 兼容 transparent 模式问题 安卓设置 setSpecialEffects 无效

示例代码:

官网示例:https://ext.dcloud.net.cn/plugin?id=2128 无其他改动。

setScrollRef(height) {  
    if (this.$refs['list'].setSpecialEffects) {  
        this.$refs['list'].setSpecialEffects({  
            id: this.parentId,  
            headerHeight: height-90 //IOS端修改这个值达到  兼容  titleNView 的   "type":"transparent", 但是安卓端完全无效。  
        });        
    }  
}

操作步骤:

设置

"titleNView": {  
    "type":"transparent"  
}

预期结果:

兼容渐变头部 type:"transparent" ,通过 this.$refs[‘list’].setSpecialEffects 调整吸顶距离,和ios端一致。

实际结果:

安卓端 设置 this.$refs[‘list’].setSpecialEffects 完全无效。

bug描述:

官网示例:https://ext.dcloud.net.cn/plugin?id=2128 无其他改动,只有吧 titleNView 里改为 type:"transparent" 即 滑动自适应 后,安卓端无法 通过 this.$refs[‘list’].setSpecialEffects来调整 吸顶距离,但是IOS端正常,

下面两张动图分别是 红米 note7 和 iPhone XR 可以看出 iPhone XR 通过 this.$refs[‘list’].setSpecialEffects调整 吸顶高度后完美兼容 type:"transparent"


更多关于uni-app swiper-list 兼容 transparent 模式问题 安卓设置 setSpecialEffects 无效的实战教程也可以访问 https://www.itying.com/category-93-b0.html

8 回复

负责人DCloud_Android_ST不回应一下吗,哪怕一个句号也行啊!!!

更多关于uni-app swiper-list 兼容 transparent 模式问题 安卓设置 setSpecialEffects 无效的实战教程也可以访问 https://www.itying.com/category-93-b0.html


原生titleNView不好用用自定义titleNView啊

老兄现在是怎么处理啊

android 暂时未适配headerHeight

这个问题能解决吗?我去年就提了bug

这个问题能解决吗,应用场景挺多的啊。。。!

这是一个已知的安卓平台兼容性问题。在 titleNView 设置为 "type":"transparent" 时,安卓端的 setSpecialEffects 方法确实存在失效的情况。

问题原因在于安卓平台对透明导航栏模式下滚动容器的布局计算与iOS存在差异。当启用透明导航栏时,安卓系统可能没有正确识别滚动容器的实际可视区域,导致 setSpecialEffects 的参数计算出现偏差。

目前可行的解决方案:

  1. 条件编译处理:针对安卓平台使用不同的布局计算方式
setScrollRef(height) {
    if (this.$refs['list'].setSpecialEffects) {
        #ifdef APP-PLUS
        if (plus.os.name.toLowerCase() === 'android') {
            // 安卓端特殊处理
            const adjustedHeight = height - 90 + '你的安卓端额外偏移量'
            this.$refs['list'].setSpecialEffects({
                id: this.parentId,
                headerHeight: adjustedHeight
            });
        } else {
        #endif
            this.$refs['list'].setSpecialEffects({
                id: this.parentId,
                headerHeight: height - 90
            });
        #ifdef APP-PLUS
        }
        #endif
    }
}
回到顶部