私は崩壊しているツールバーを持っています。それが崩壊すると、私はアプリのバーのタイトルを設定しますが、そのアプリのバーのタイトルを削除することはできません。展開条件(verticalOffset == 0)が実行されていますが、タイトルが変更されていないようです。なぜアプリケーションバーのタイトルが変更されないのですか?
public class MovieDetailsActivity extends AppCompatActivity implements AppBarLayout.OnOffsetChangedListener{
private CollapsingToolbarLayout collapsingToolbarLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movie_details);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
...
collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
appBarLayout.addOnOffsetChangedListener(this);
...
setTitle("");
...
}
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
//Closed
setTitle("Tmovies");
Log.i("test","Closed");
} else if (verticalOffset == 0) {
// Expanded
setTitle("");
Log.i("test","Expanded");
} else {
// Somewhere in between
}
}
}
残念ながらまだ動作していません – ams92