답변

0

당신은 CollapsingToolbarLayout 축소 또는 확장시기를 결정하고 제목의 설정 AppBarLayout에 OnOffsetChangedListener 추가 할 수 있습니다.

final CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); 
collapsingToolbarLayout.setTitle(" "); 

AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout); 
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { 
    boolean isShow = false; 
    int scrollRange = -1; 

    @Override 
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { 
     if (scrollRange == -1) { 
      scrollRange = appBarLayout.getTotalScrollRange(); 
     } 
     if (scrollRange + verticalOffset == 0) { 
      collapsingToolbarLayout.setTitle("Title"); 
      isShow = true; 
     } else if(isShow) { 
      collapsingToolbarLayout.setTitle(" ");//carefull there should a space between double quote otherwise it wont work 
      isShow = false; 
     } 
    } 
});