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中倍增偏移量的问题。

相关内容

热门资讯

WPK辅助!微扑克脚本开挂ai... WPK辅助!微扑克脚本开挂ai,aapoker怎么设置抽水,好像真的有ai开挂演示1、下载好aapo...
WPK脚本!微扑克方法透视挂a... WPK脚本!微扑克方法透视挂ai,wpk透视是真的吗,竟然存在有ai透视挂模块;1、wpk透视是真的...
WPK下载!微扑克教程辅助ai... WPK下载!微扑克教程辅助ai,wpk可以作弊吗,本来是真的有ai辅助积累wpk可以作弊吗能透视中分...
WPK辅助!德州扑克插件开挂a... WPK辅助!德州扑克插件开挂ai,aapoker怎么提高中牌率,竟然存在有ai开挂练习1、点击下载安...
WPK辅助!WPK软件辅助ai... WPK辅助!WPK软件辅助ai,德扑之星辅助功能如何打开,本来是真的有ai辅助策略;1、点击下载安装...
WPK辅助!WePoKer软件... WPK辅助!WePoKer软件辅助ai,wpk有那种辅助吗,好像有ai辅助妙招一、wpk有那种辅助吗...
WPK私人局!AApoker教... 您好,werplan脚本这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多...
WPK透视!菠萝智星德州工具透... WPK透视!菠萝智星德州工具透视ai,约局吧怎么看有没有挂,确实真的是有ai透视讲义约局吧怎么看有没...
WPK私人局!AApoker神... WPK私人局!AApoker神器辅助器ai,wpk有作弊吗,本来是真的有ai辅助器总结1、该软件可以...
WPK靠谱!德扑之星攻略辅助器... WPK靠谱!德扑之星攻略辅助器ai,AApoker辅助器,都是是有ai辅助器要领1、AApoker辅...