Currently, I'm following suggestion from https://stackoverflow.com/a/29748810/72437 , in order to change status bar color, when entering contextual action mode.
However, from the following video, https://www.youtube.com/watch?v=2Ra56_eh7uk , we can observe that color change always happen at status bar, only then color change on toolbar will follow.
Is there any way, to make color change happens simultaneously, on both status bar and toolbar.
@SuppressLint("NewApi")
private class ModeCallback implements ListView.MultiChoiceModeListener {
public boolean onCreateActionMode(android.view.ActionMode mode,
android.view.Menu menu) {
...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Activity activity = getActivity();
if (activity != null) {
activity.getWindow().setStatusBarColor(actionModeStatusBarColor);
}
}
return true;
}
public boolean onPrepareActionMode(android.view.ActionMode mode, android.view.Menu menu) {
return true;
}
public boolean onActionItemClicked(android.view.ActionMode mode, android.view.MenuItem item) {
switch (item.getItemId()) {
....
}
return false;
}
public void onDestroyActionMode(android.view.ActionMode mode) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Activity activity = getActivity();
if (activity != null) {
activity.getWindow().setStatusBarColor(colorPrimaryDark);
}
}
}
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
this.getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
this.getListView().setMultiChoiceModeListener(new ModeCallback());
...