下面列出了android.support.design.widget.CollapsingToolbarLayout#setFitsSystemWindows ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void setStatusBarColorForCollapsingToolbar(Activity activity, AppBarLayout appBarLayout, CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar, int statusColor) {
Window window = activity.getWindow();
window.clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
window.addFlags(Integer.MIN_VALUE);
window.setStatusBarColor(0);
window.getDecorView().setSystemUiVisibility(0);
View mChildView = ((ViewGroup) window.findViewById(16908290)).getChildAt(0);
if (mChildView != null) {
ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
return insets;
}
});
ViewCompat.setFitsSystemWindows(mChildView, true);
ViewCompat.requestApplyInsets(mChildView);
}
((View) appBarLayout.getParent()).setFitsSystemWindows(true);
appBarLayout.setFitsSystemWindows(true);
collapsingToolbarLayout.setFitsSystemWindows(true);
collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(true);
toolbar.setFitsSystemWindows(false);
collapsingToolbarLayout.setStatusBarScrimColor(statusColor);
}
public static void setStatusBarColorForCollapsingToolbar(Activity activity, AppBarLayout appBarLayout, CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar, int statusColor) {
Window window = activity.getWindow();
window.addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
View mContentChild = ((ViewGroup) window.findViewById(16908290)).getChildAt(0);
mContentChild.setFitsSystemWindows(false);
((View) appBarLayout.getParent()).setFitsSystemWindows(false);
appBarLayout.setFitsSystemWindows(false);
collapsingToolbarLayout.setFitsSystemWindows(false);
collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(false);
toolbar.setFitsSystemWindows(true);
if (toolbar.getTag() == null) {
CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
lp.height += getStatusBarHeight(activity);
toolbar.setLayoutParams(lp);
toolbar.setTag(Boolean.valueOf(true));
}
int statusBarHeight = getStatusBarHeight(activity);
removeFakeStatusBarViewIfExist(activity);
removeMarginTopOfContentChild(mContentChild, statusBarHeight);
}