Android15沉浸式界面顶部有问题
往往开发人员的手机没这么高级,客户或者老板的手机是Android15的。 我明明就设了状态栏透明,我的手机也没问题。但Android15是有问题的。
先看下有问题的界面:
解决方案:
处理1:
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM){if (!isStatusBarTranslucent()){vgMain.setFitsSystemWindows(true);} else {getWindow().getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {@NonNull@Overridepublic WindowInsets onApplyWindowInsets(@NonNull View v, @NonNull WindowInsets insets) {if (insets.getSystemWindowInsetBottom() > 0){getWindow().getDecorView().setPadding(0,0,0,insets.getSystemWindowInsetBottom());}return insets;}});}}
再调用那边:
@Overridepublic void onCreate(Bundle savedInstanceState) {setStatusBarTranslucent(true);super.onCreate(savedInstanceState);initHeadView(R.layout.activity_sesame_auth_info,false);StatusBarUtils.setStatusBarTranslucent(this);}
可能你看不懂我代码的先后顺序,不要紧。你有地方调用处理1下面的代码即可。
实在有问题,可以私信我。