New Android Design Library bug with AppBarLayout and Toolbar

前端 未结 5 1804
被撕碎了的回忆
被撕碎了的回忆 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:15

    Change your Design Library with New Version build.gradle file in app folder like:

    compile 'com.android.support:design:22.2.1'

    As Updated in +AndroidDevelopers

    I got output like:

    enter image description here

    It will helps you.

    Thanks :)

    0 讨论(0)
  • 2020-12-02 19:17

    I had same problem, my toolbar was displaying wrong on API level greater than 21. I was using android.support.v7.widget.Toolbar as supportActionBar() and below content is in fragment, see pictures: on aplication start, toolbar is displaying wrong and when i colapse android.support.design.widget.CollapsingToolbarLayout, the picture is not hidden completely

    I resolved this when i added android:fitsSystemWindows="true" attribute to the root element of view where Toolbar is located.

    Now: toolbar is displaying normal and picture is hidden completely

    0 讨论(0)
  • 2020-12-02 19:21

    had the same problem put in style with windowActionBar and windowNoTitle and decided my problem.

    <style name="AppTheme.base" parent="Base.Theme.AppCompat.Light.DarkActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
           <item name="windowActionBar">false</item>
            <item name="windowNoTitle">true</item>
        </style>
    
    0 讨论(0)
  • 2020-12-02 19:25

    Looks like this is a bug in com.android.support:design:22.2.0. It will be fixed, it's marked as future release. So lets hope it will be soon. Links with issues: https://code.google.com/p/android/issues/detail?id=175240 and https://code.google.com/p/android/issues/detail?id=175069

    0 讨论(0)
  • 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);}
    
    0 讨论(0)
提交回复
热议问题