Java Code Examples for android.support.design.widget.CollapsingToolbarLayout#setFitsSystemWindows()

The following examples show how to use android.support.design.widget.CollapsingToolbarLayout#setFitsSystemWindows() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusBarCompatLollipop.java    From FimiX8-RE with MIT License 6 votes vote down vote up
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);
}
 
Example 2
Source File: StatusBarCompatKitKat.java    From FimiX8-RE with MIT License 6 votes vote down vote up
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);
}