首页其他界面有标题而我的界面无标题,但是不需要沉浸到状态栏的解决办法。
在首页xml根目录设置
android:clipChildren="false"
android:clipToPadding="false"
首页activity代码设置
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.navigation_my) {
binding.toolBar.setAlpha(0);
binding.appBarLayout.setAlpha(0);4
// ObjectAnimator.ofFloat(binding.appBarLayout, "elevation", 1).setDuration(1).start();
}else{
binding.toolBar.setAlpha(1);
binding.appBarLayout.setAlpha(1);
}
我的界面fragment代码设置
我的界面根目录设置TranslationY为状态栏高度,同时隐藏actionbar
int statusBarHeight = AppUtils.getStatusBarHeight(getActivity());标签:appBarLayout,界面,状态栏,binding,getBinding,无标题,setAlpha,首页 From: https://blog.51cto.com/u_15458814/5883436
int paddingHeight = statusBarHeight + AppUtils.getActionBarHeight(getActivity());
getBinding().rootLinelayout.setTranslationY(-paddingHeight);
ConstraintLayout.LayoutParams layoutparam = (ConstraintLayout.LayoutParams) getBinding().headWrap.getLayoutParams();
layoutparam.topMargin = statusBarHeight;
getBinding().headWrap.setLayoutParams(layoutparam);