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下面的代碼即可。
實在有問題,可以私信我。