AndroidR(Api30)中WindowInsetListener会使偏移量翻倍。
创始人
2024-10-10 00:31:49
0

在Android R中,WindowInsetListener在布局中使用时会使偏移量增加两倍。为了解决这个问题,需要在代码中使用以下方法来获得将偏移量倍增的正确值。

  1. 在布局文件中设置fitsSystemWindows属性为true:

    

  1. 在代码中使用以下方法来获得修正后的偏移量值:
ViewCompat.setOnApplyWindowInsetsListener(view, new OnApplyWindowInsetsListener() {
    @Override
    public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
        int topInset = insets.getSystemWindowInsetTop() / 2;
        int bottomInset = insets.getSystemWindowInsetBottom() / 2;
        int leftInset = insets.getSystemWindowInsetLeft() / 2;
        int rightInset = insets.getSystemWindowInsetRight() / 2;
        return insets.inset(leftInset, topInset, rightInset, bottomInset);
    }
});

通过使用fitsSystemWindows属性来设置偏移量,在代码中使用以上方法来获取正确的偏移量值。这将解决WindowInsetListener在Android R中倍增偏移量的问题。

相关内容

热门资讯

开挂辅助平台"wep... 开挂辅助平台"wepoker手机版辅助"开挂(透视)辅助插件(有挂分享)1、下载安装好wepoker...
开挂辅助脚本"德州局... 开挂辅助脚本"德州局透视脚本"开挂(透视)辅助脚本(有挂功能)《详细加薇136704302咨询》游戏...
开挂辅助下载"德普之... 开挂辅助下载"德普之星透视辅助插件"开挂(透视)辅助安装(有挂教学)您好:德普之星透视辅助插件这款游...
开挂辅助下载"wep... 开挂辅助下载"wepokerplus万能挂"开挂(透视)辅助安装(有挂头条);无需打开直接搜索薇:1...
开挂辅助软件"来玩a... 开挂辅助软件"来玩app破解版"开挂(透视)辅助插件(有挂攻略);无需打开直接搜索薇:1367043...
开挂辅助安装"aap... 开挂辅助安装"aapoker俱乐部靠谱吗"开挂(透视)辅助神器(有挂分析) 了解更多开挂安装加(13...
开挂辅助平台"wpk... >>您好:wpk控制牌是真的吗确实是有挂的,很多玩家在这款wpk控制牌是真的吗游戏中打牌都会发现很多...
开挂辅助工具"拱趴大... 开挂辅助工具"拱趴大菠萝有什么挂"开挂(透视)辅助软件(有挂教学) >>您好:软件加薇1367043...
开挂辅助脚本"pok... 开挂辅助脚本"pokemmo免费脚本"开挂(透视)辅助安装(确实有挂);无需打开直接搜索薇:1367...
开挂辅助插件"wep... wepoker游戏的安装教程是一款专注玩家量身打造的游戏记牌类型软件,在wepoker游戏的安装教程...