New Android Design Library bug with AppBarLayout and Toolbar

前端 未结 5 1834
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 18:52

I am using the new Android Design Library based on this example chrisbanes/cheesesquare in github and here

I have run the example and I am having problems with Toolb

5条回答
  •  星月不相逢
    2020-12-02 19:30

    Here is some working workaround for API 21:

     if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
        marginResult = 0;
        int resourceId = getResources().getIdentifier(getString(R.string.identifier_status_bar_height), getString(R.string.identifier_dimen), getString(R.string.identifier_android));    
        if (resourceId > 0) {
            marginResult = getResources().getDimensionPixelSize(resourceId)*2;
         }
        CollapsingToolbarLayout.LayoutParams params = (CollapsingToolbarLayout.LayoutParams) mToolbar.getLayoutParams();
        params.topMargin -= marginResult;
        mToolbar.setLayoutParams(params);}
    

提交回复
热议问题