CollapsingToolbarLayout | Scrolling and layout issues 2

后端 未结 2 984
梦毁少年i
梦毁少年i 2020-12-23 19:07

Related Questions

CollapsingToolbarLayout | Scrolling and layout issues

Backgroud

I want to use 2 different fragments that will allow me to chan

相关标签:
2条回答
  • 2020-12-23 19:56

    Question 1

    Add android:fitsSystemWindows="true" to your AppBarLayout, CollapsingToolbarLayout, and to your ImageView.

    I'm guessing a part of your image is below the status bar (due to these lines being missing) which is why you can't see the top of the image.

    Question 2

    collapseMode="pin" only affects how the Toolbar reacts to collapsing (hence why it is called collapseMode and not scrollFlags).

    In almost all cases when using CollapsingToolbarLayout, you should be using scroll|exitUntilCollapsed for your scrollFlags - this keeps the collapsed Toolbar visible even when you scroll downward.

    Question 3

    This is due to using scroll|enterAlways. Change your flags as per #2

    Question 4

    As mentioned in the answer to your related question, you need to call getSupportActionBar().setDisplayHomeAsUpEnabled(true); to show the Up button:

     @Override
     protected void onCreate(Bundle savedInstanceState) {
    
      super.onCreate(savedInstanceState);
      setContentView(R.layout.test);
    
      final Toolbar toolbar = (Toolbar) findViewById(R.id.anim_toolbar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    
      CollapsingToolbarLayout collapsingToolbar =
          (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
      collapsingToolbar.setTitle("Avengers: Age of Ultron");
    }
    
    0 讨论(0)
  • 2020-12-23 20:01

    Remove app:contentScrim="?attr/colorPrimary" from your layout XML in CollapsingToolBarLayout tag. It will show the back button in toolbar

    0 讨论(0)
提交回复
热议问题